Transforms an array including an identifier to an object.

@param array $idObject

@throws TransformationFailedException if object is not found

@return object|null
340590
public function reverseTransform($idObject)
    {
        if (!is_array($idObject)) {
            return;
        }

        $identifier = current(array_values($this->om->getClassMetadata($this->entityName)->getIdentifier()));
        $id = $idObject[$identifier];

        $object = $this->om
            ->getRepository($this->entityName)
            ->findOneBy([$identifier => $id]);

        if (null === $object) {
            throw new TransformationFailedException(sprintf(
                'An object with identifier key "%s" and value "%s" does not exist!',
                $identifier, $id
            ));
        }

        return $object;
    }
20306
public function transform($value)
    {
        if (null !== $value && !is_scalar($value)) {
            throw new TransformationFailedException('Expected a scalar.');
        }

        if ('' === $value || null === $value) {
            return null;
        }

        return [$value];
    }
722554
public function transform($value)
    {
        if ($value === null) {
            return null;
        }

        if (!$value instanceof $this->enumClass) {
            throw new TransformationFailedException(sprintf(
                'Expected instance of "%s". Got "%s".',
                $this->enumClass,
                \is_object($value) ? \get_class($value) : \gettype($value)
            ));
        }

        return $value->getValue();
    }
407224
public function toItem($object): ? Item
    {
        foreach ($this->writeTransformers as $writeTransformer) {
            if ($writeTransformer->isValidObject($object)) {
                $item = $writeTransformer->toItem($object);
                $this
                    ->eventDispatcher
                    ->dispatch(
                        'apisearch.item_transformed',
                        new ItemTransformed(
                            $item,
                            $object
                        )
                    );

                return $item;
            }
        }

        return null;
    }
649458
public function reverseTransform($id)
    {
        if (!$id) {
            return null;
        }
        if (!$entity = $this->retrieve($id)) {
            throw new TransformationFailedException(sprintf(
                '%s#%s cannot be found.',
                $this->entityClass,
                $id
            ));
        }

        return $entity;
    }
1088260
public function getObjectIdentity($object)
    {
        foreach ($this->configurations as $config) {
            if ($config->isRelevant($object)) {
                return $config->getObjectIdentity();
            }
        }

        return null;
    }
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);
    }
559363
private function deserializeObjectRecursively($serializedObject)
    {
        Assert::keyExists($serializedObject, 'class', "Key 'class' should be set.");
        Assert::keyExists($serializedObject, 'payload', "Key 'payload' should be set.");

        $reflection = new ReflectionClass($serializedObject['class']);
        $properties = $reflection->getProperties();
        $object = $reflection->newInstanceWithoutConstructor();

        foreach ($serializedObject['payload'] as $name => $value) {
            $matchedProperty = $this->findProperty($properties, $name);
            if (null === $matchedProperty) {
                throw new SerializationException(sprintf(
                    'Property \'%s\' not found for object \'%s\'',
                    $name,
                    $serializedObject['class']
                ));
            }

            $value = $this->deserializeValue($value);

            $matchedProperty->setAccessible(true);
            $matchedProperty->setValue($object, $value);
            $matchedProperty->setAccessible(false);
        }

        return $object;
    }
733016
public function transform($value)
    {
        if (null === $value) {
            return null;
        }

        if (!$value instanceof Language) {
            throw new TransformationFailedException('Expected a ' . Language::class . ' object.');
        }

        return $value->languageCode;
    }
118876
public function reverseTransform($id)
	{
        if (!$id || $id === 'Add' || empty($id))
		{
			return null;
		}

		if (!is_array($id))
		{

			$entity = $this->entityRepository->find($id);
			if (null === $entity)
			{
				throw new TransformationFailedException(
					sprintf(
						'A %s with id "%s" does not exist!',
						$this->entityType,
						$id
					)
				);
			}

			return $entity;
		}

		return $id;
	}
841831
public function transform($array)
    {
        if (null === $array) {
            return '';
        }

        if (!is_array($array)) {
            throw new TransformationFailedException('Expected an array.');
        }

        foreach ($array as &$value) {
            $value = sprintf('%s%s%s',
                str_repeat(' ', $this->paddingLeft),
                $value,
                str_repeat(' ', $this->paddingRight)
            );
        }

        $string = trim(implode($this->delimiter, $array));

        return $string;
    }
923755
public function transform($value)
    {
        if (null === $value) {
            return null;
        }

        if (!$value instanceof APIRoleAssignment) {
            throw new TransformationFailedException('Expected a ' . APIRoleAssignment::class . ' object.');
        }

        return $value->id;
    }
1059802
public function reverseTransform($array)
    {
        if ('' === $array || null === $array) {
            $array = [];
        }

        $values = [];
        foreach ($array as $slug => $field) {
            if ($field === null) {
                continue;
            }
            if (!$field instanceof FieldInterface) {
                throw new TransformationFailedException(sprintf('Expected a %s object.', FieldInterface::class));
            }
            if (!$field->getContentType()) {
                $field->setContentType($this->contentType);
            }
            $values[] = $field;
        }

        return new ArrayCollection($values);
    }
375291
public function reverseTransform($array)
    {
        $medias = new \Doctrine\Common\Collections\ArrayCollection();

        if (!$array || !preg_match('#^[0-9]+(;[0-9])*$#', $array)) {
            return $medias;
        }

        $ids = explode(';', $array);

        foreach ($ids as $id) {
            $media = $this->objectManager
                ->getRepository($this->mediaClass)
                ->find($id)
                ;

            if (null === $media) {
                throw new TransformationFailedException(sprintf(
                    'Media "%s" is not found !',
                    $id
                ));
            }

            $medias->add($media);
        }

        return $medias;
    }
158690
public function transform($collection)
    {
        if (null === $collection) {
            return [];
        }

        if (!$collection instanceof Collection) {
            throw new TransformationFailedException(sprintf('Expected a %s object.', Collection::class));
        }

        $values = [];
        foreach ($collection as $field) {
            $values[$field->getId()] = $field;
        }

        return $values;
    }
490142
public function transform($value): ?int
    {
        if (null === $value) {
            return null;
        }

        if (!$value instanceof TrashItem) {
            throw new TransformationFailedException('Expected a ' . TrashItem::class . ' object.');
        }

        return $value->id;
    }
304280
public function transform($value): ?string
    {
        if (null === $value) {
            return null;
        }

        if (!is_array($value) || array_diff(['id', 'module', 'function'], array_keys($value))) {
            throw new TransformationFailedException('Expected a valid array of data.');
        }

        return implode(':', [$value['id'], $value['module'], $value['function']]);
    }