(non-PHPdoc)
@see \Symfony\Component\Form\DataTransformerInterface::transform()
15211
public function transform($entity)
    {   
        if (null === $entity || '' === $entity) {
            return null;
        }
        
        if (!is_object($entity)){
            throw new UnexpectedTypeException($entity, 'object');
        }
        
        if ($entity instanceof Proxy && !$entity->__isInitialized()){
            $entity->__load();
        }

        $meta = $this->om->getClassMetadata(get_class($entity));
        $id = $meta->getSingleIdReflectionProperty()->getValue($entity);

        return $id;
    }
859080
public function reverseTransform($value)
    {
        if (null === $value || '' === $value) {
            return null;
        }

        if (!is_scalar($value)) {
            throw new TransformationFailedException('Expected a scalar.');
        }

        $entity = $this->repository->find($value);

        if (null === $entity) {
            throw new TransformationFailedException(
                sprintf('Entity %s with identifier "%s" not found.', $this->className, $value)
            );
        }

        return $entity;
    }
968879
protected function transformProperties()
    {
        $properties = empty($this->data[static::FIELD_PROPERTIES]) ? [] : $this->data[static::FIELD_PROPERTIES];
        $this->data[static::FIELD_PROPERTIES] = new DatasourceProperties($properties);
    }
1101414
protected function transform($data)
    {
        if (!$data instanceof GetSchema\Schema) {
            throw new Exception('Schema instance missing.');
        }

        $field = $this->specializedFIelds[0];
        $returnData = [];

        foreach ($data->getTableDefinitions() as $definition) {
            $returnData[] = [
                $field => $definition->getName(),
                0 => $definition->getName(),
            ];
        }

        return $returnData;
    }
794225
protected function transformKeysCase(array $transformed)
    {
        // Get the config for how many levels of keys to transform
        $levels = config('api.formatsOptions.transform_keys_levels', null);

        /**
         * Transform all keys to required case, to the specified number of levels (by default, infinite)
         */
        $transformed = $this->formatKeyCase($transformed, $levels);

        /*
         * However, if the level is 1, we also want to transform the first level of keys in a json field which has been cast to array
         */
        if ($levels == 1 && ! is_null($this->model)) {
            foreach ($this->model->getCasts() as $fieldName => $castType) {
                if ($castType == 'array') {
                    $fieldNameFormatted = $this->formatKeyCase($fieldName);
                    if (array_key_exists($fieldNameFormatted, $transformed)) {
                        $transformed[$fieldNameFormatted] = $this->formatKeyCase($transformed[$fieldNameFormatted]);
                    }
                }
            }
        }

        return $transformed;
    }
231414
public static function transform($object, $request)
	{
		$transformer = static::getTransformer($object);
		if (!$transformer) {
			return $object;
		}
		
		return $transformer->transform($object, $request);
	}
364476
public function transform(QueryBuilder $qb, $dqlAlias)
    {
        if (!in_array(strtolower($this->functionName), self::$doctrineFunctions) &&
            !$qb->getEntityManager()->getConfiguration()->getCustomStringFunction($this->functionName) &&
            !$qb->getEntityManager()->getConfiguration()->getCustomNumericFunction($this->functionName) &&
            !$qb->getEntityManager()->getConfiguration()->getCustomDatetimeFunction($this->functionName)
        ) {
            throw new InvalidArgumentException(sprintf('"%s" is not a valid function name.', $this->functionName));
        }

        $arguments = ArgumentToOperandConverter::convert($this->arguments);
        foreach ($arguments as $key => $argument) {
            $arguments[$key] = $argument->transform($qb, $dqlAlias);
        }

        return sprintf('%s(%s)', $this->functionName, implode(', ', $arguments));
    }
729481
public function transform($data)
    {
        if ($data instanceof FormBuilder) {
            $response = $data->getRawResponse();

            foreach ($response['fieldsets'] as $fieldset) {
                $this->transformFieldset($fieldset);
            }

            return [
                'form' => [
                    'name'      => array_get($response, 'name'),
                    'rules'     => array_get($response, 'rules', []),
                    'fieldsets' => $this->fieldsets,
                ],
            ];
        }

        return parent::transform($data);
    }
24853
public function transform()
    {
        $originalData = $this->getData();
        $transformedData = $this->transformer->transform();

        $restData = $this->unsetKeys($originalData, $this->transformer->getSupportedKeys());
        $this->checkIfAllValuesWereProceeded($restData, $this->transformer);

        return $transformedData;
    }
168417
protected function transform($data)
    {
        if (!$data instanceof GetSchema\Schema) {
            throw new Exception('Data is not a Schema.');
        }

        $createExpr = $this->getCreateQueryFromSchema($data);
        $indices = $createExpr->getIndices();
        $columns = $createExpr->getColumns();

        $returnData = [];

        /* @var  $column Query\ColumnExpression */
        foreach ($columns as $column) {
            $row                      = self::$tplData;
            $columnType               = $column->getColumnType();
            $dataType                 = $columnType->getDataType();

            $key = $this->getKeyTypeFromColumn($column, $indices);
            $default = $this->getDefaultValueFromColumnType($columnType);

            $row[self::KEY_FIELD]     = $row[0] = $column->getColumnName();
            $row[self::KEY_TYPE]      = $row[1] = $columnType->getSqlType();
            $row[self::KEY_COLLATION] = $row[2] = $dataType->getCollation() !== '' ? $dataType->getCollation() : null;
            $row[self::KEY_NULL]      = $row[3] = $columnType->isNullable() ? 'YES' : 'NO';
            $row[self::KEY_KEY]       = $row[4] = $key;
            $row[self::KEY_DEFAULT]   = $row[5] = $default;

            $returnData[] = $row;
        }

        return $returnData;
    }
1209087
public function transform($trans)
    {
        $this->flushFieldsCache();
        $newFields = new FieldList();
        foreach ($this as $field) {
            $newFields->push($field->transform($trans));
        }
        return $newFields;
    }
640873
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->resetModelTransformers();
        $builder->addModelTransformer(
            new CallbackTransformer(
                function ($originalData) {
                    return $originalData;
                },
                function ($submittedData) use ($options) {
                    if (null === $submittedData || '' === $submittedData) {
                        return null;
                    }

                    $eavEntity = $this->repository->find($submittedData);
                    if (!$eavEntity instanceof DataInterface) {
                        throw new TransformationFailedException('Data should be a DataInterface');
                    }
                    $this->checkFamily($eavEntity, $options['allowed_families']);

                    return $eavEntity;
                }
            )
        );

        $builder->resetViewTransformers();
        $builder->addViewTransformer(
            new CallbackTransformer(
                function ($originalData) {
                    if ($originalData instanceof DataInterface) {
                        return $originalData->getId();
                    }

                    return $originalData;
                },
                function ($submittedData) {
                    return $submittedData;
                }
            )
        );
    }
335989
public function transform($value)
    {
        if (null === $value) {
            return '';
        } elseif ($value instanceof Collection) {
            $values = $value->toArray();
        } elseif (is_array($value)) {
            $values = $value;
        } else {
            throw new TransformationFailedException('TagTransformer expects to transform an array or Collection value');
        }

        $propertyAccessor = $this->propertyAccessor;
        $property = $this->property;
        $values = array_map(function ($value) use ($propertyAccessor, $property) {
            return $propertyAccessor->getValue($value, $property);
        }, $values);

        return implode(',', $values);
    }
991255
protected function callTransform($model)
    {

        // Use normal Transformer
        $returnData = $this->transform( $model );

        // Include default includes
        $returnData = $this->includeDefaultIncludes( $model, $returnData );

        // Include available includes
        $returnData = $this->includeAvailableIncludes( $model, $returnData );

        return $returnData;
    }
811402
public function transform($value)
    {
        if (null === $value) {
            $value = $this->fieldType->getEmptyValue();
        }

        return array_merge(
            $this->getDefaultProperties(),
            [
                'hasController' => $value->hasController,
                'loop' => $value->loop,
                'autoplay' => $value->autoplay,
                'width' => $value->width,
                'height' => $value->height,
            ]
        );
    }
143982
public function transform($source)
    {
        if ($this->discoverInterface()) {
            $this->nb_interface->transform($source);
        } else {
            throw new ENabuRenderException(
                ENabuRenderException::ERROR_RENDER_TRANSFORM_NOT_FOUND,
                array($this->nb_descriptor->getKey())
            );
        }
    }
1093598
public function transform($data)
    {
        if (is_null($data)) {
            return false;
        }

        if (! is_string($data)) {
            throw new DataTransformerException('A string value is expected.');
        }

        if (empty($data)) {
            return false;
        }

        if (in_array($data, ['off', 'no'], true)) {
            return false;
        }

        return true;
    }