Transforms JSON to Collection entities
@param string $value
@return Collection
772038
public function reverseTransform($value)
    {
        $collection = new ArrayCollection();

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

        if (!is_string($value)) {
            throw new UnexpectedTypeException($value, 'string');
        }

        if ($this->onlyKeysInReverse) {
            $ids = \explode($this->separatorIfOnlyKeysInReverse, $value);
        } else {
            $ids = array();
            foreach (json_decode($value, true) as $subValue) {
                if (!empty($subValue[$this->arrayIdentifierName])) {
                    $ids[] = $subValue[$this->arrayIdentifierName];
                }
            }
        }

        $ids = \array_unique($ids);
        if (count($ids) == 0) {
            return $collection;
        }
        if (count($ids) > $this->maxResults) {
            throw new TransformationFailedException(
                sprintf('This collection should contain %s elements or less.', $this->maxResults)
            );
        }

        try {
            $hash = $this->getCacheHash($ids);
            if (array_key_exists($hash, $this->cachedResults)) {
                $collection = $this->cachedResults[$hash];
            } else {
                //Result not in cache

                $queryBuilderLoader = new ORMQueryBuilderLoader($this->queryBuilder);

                foreach ($queryBuilderLoader->getEntitiesByIds($this->identifier, $ids) as $entity) {
                    $collection->add($entity);
                }
                $this->cachedResults[$hash] = $collection; //Saves result in cache
            }
        } catch (\Exception $e) {
            throw new TransformationFailedException('Tranformation: Query Error');
        }

        return $collection;
    }
17656
protected function flattenList($value)
    {
        if ($value[0] === Type::T_LIST && count($value[2]) === 1) {
            return $this->flattenList($value[2][0]);
        }

        return $value;
    }
120865
protected function serializeValue($value)
    {
        if (is_string($value)) {
            return $value;
        }
        if (is_object($value) || is_array($value)) {
            return json_encode($value);
        }
    }
983659
public function serialize($value) {
        $filters = $this->getFilters();
        for ($i = count($filters) - 1; $i >= 0; --$i) {
            $value = $filters[$i]->fromValue($value);
        }
        return $this->toData($value);
    }
1089407
public static function all(string $key = NULL, ?string $value = NULL): Collection {
        return static::attempt(function () use ($key, $value): Collection {
            $db = DB::instance();
            if ($key === NULL)
                $dat = $db -> selectall(static::table());
            else $dat = $db -> find(static::table(), implode(',', static::columns()), [$key => $value]);
            $objarr = new Collection();
            foreach ($dat as $local_data) {
                $ld = new static(['id' => $local_data['id']], $local_data);
                $objarr[] = $ld;
            }
            return $objarr;
        });
    }
562448
public function transform($value)
    {
        if ($value instanceof JsonSerializable || $value instanceof StdClass) {
            return json_encode($value);
        }

        // If a toJson() method exists, the object can cast itself automatically.
        if (method_exists($value, 'toJson')) {
            return $value;
        }

        // Otherwise, if the object doesn't even have a __toString() method, we can't proceed.
        if (! method_exists($value, '__toString')) {
            throw new \Exception('Cannot transform this object to JavaScript.');
        }

        return "'{$value}'";
    }
937809
public function reverseTransform($value)
    {
        if ($value === null) {
            $value = [];
        }

        $arrayCollection = new ArrayCollection();

        foreach ($value as $v) {
            $arrayCollection->add($v);
        }

        return $arrayCollection;
    }
197970
private function copyValue($value)
    {
        if (is_array($value)) {
            return $this->copyArray($value, true);
        }
        if (!is_object($value)) {
            return $value;
        }
        if ($value instanceof Collection) {
            return new ArrayCollection($this->copyArray($value->toArray(), false));
        }
        if ($value instanceof \Traversable) {
            throw new ClonerException(sprintf('Traversable class "%s" is not supported.', ClassUtils::getClass($value)));
        }

        return $this->cloneObject($value, false);
    }
1124744
public function resolve($value)
    {
        foreach ($this->transformers as $transformer) {
            if ($transformer->supports($value)) {
                return $transformer;
            }
        }

        return new NullTransformer();
    }
576898
private function convertArrayToEntityValue(array $value)
    {
        $excludes = $this->pluck(Entity::EXCLUDE_FROM_INDEXES, $value, false) ?: [];

        $properties = [];
        foreach ($value as $key => $val) {
            $properties[$key] = $this->valueObject(
                $val,
                in_array($key, $excludes)
            );
        }

        if (!$properties) {
            $properties = (object) $properties;
        }

        return [
            'entityValue' => [
                'properties' => $properties
            ]
        ];
    }
1369779
public function serialize($value)
    {
        $this->noMappingGuard();

        if (\is_array($value) && !empty($value[Serializer::MAP_TYPE])) {
            $data = $this->serializedArray($value);
        } else {
            $data = $this->serializeObject($value);
        }

        return \json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
    }
214494
public static function convertToDb($value)
    {
        if (!is_array($value)) {
            return [];
        }

        // see DateType::convertToDatabaseValue()
        $convertor = function ($value) {
            if ($value === null || $value instanceof \MongoDate) {
                return $value;
            }

            try {
                $datetime = DateType::getDateTime($value);
                return new \MongoDate($datetime->format('U'), $datetime->format('u'));
            } catch (\InvalidArgumentException $e) {
                return null;
            }
        };

        return array_values(array_filter(array_map($convertor, $value)));
    }
311272
public function transform($value)
    {
        $result = array();
        $workflowProfiles = $this->workflowProfileRepository->findAll();
        $contentTypes = $this->contentTypeRepository->findAllNotDeletedInLastVersion();

        $settedWorkflowProfiles = array();
        if ($value instanceof Collection) {
            foreach ($value as $workflowProfileCollectionName => $workflowProfileCollection) {
                $settedWorkflowProfiles[$workflowProfileCollectionName] = array();
                foreach ($workflowProfileCollection->getProfiles() as $workflowProfile) {
                    $settedWorkflowProfiles[$workflowProfileCollectionName][] = $workflowProfile->getId();
                }
            }
        }
        foreach ($workflowProfiles as $workflowProfile) {
            $nodeTypeId = NodeInterface::ENTITY_TYPE;
            $result[$nodeTypeId][$workflowProfile->getId()] = array_key_exists($nodeTypeId, $settedWorkflowProfiles) && in_array($workflowProfile->getId(), $settedWorkflowProfiles[$nodeTypeId]);
        }

        foreach ($contentTypes as $contentType) {
            $contentTypeId = $contentType->getContentTypeId();
            foreach ($workflowProfiles as $workflowProfile) {
                $result[$contentTypeId][$workflowProfile->getId()] = array_key_exists($contentTypeId, $settedWorkflowProfiles) && in_array($workflowProfile->getId(), $settedWorkflowProfiles[$contentTypeId]);
            }
        }

        return $result;
    }
1338137
public static function serializeValue($value)
    {
        if ($value instanceof JsonSerializable || $value instanceof \JsonSerializable) {
            return $value->jsonSerialize();
        }

        if (is_object($value)) {
            foreach (get_object_vars($value) as $nestedKey => $nestedValue) {
                $value->{$nestedKey} = self::serializeValue($nestedValue);
            }

            return $value;
        }

        if (is_array($value)) {
            foreach ($value as &$nestedValue) {
                $nestedValue = self::serializeValue($nestedValue);
            }

            return $value;
        }

        if ($value instanceof DateTime || $value instanceof \DateTimeInterface) {
            throw new DomainException('Please wrap your DateTime objects with Aplazame\Serializer\Date::fromDateTime');
        }

        if (is_float($value)) {
            throw new DomainException('Please wrap your float values with Aplazame\Serializer\Decimal::fromFloat');
        }

        return $value;
    }
680007
public function serialize($value)
    {
        $this->reset();

        return $this->serializationStrategy->serialize($this->serializeData($value));
    }
1062600
public function delete($value)
    {
        foreach (array_keys($this->collection, $value, true) as $key) {
            unset($this->collection[$key]);
        }

        return $this;
    }
484806
protected function resolveValue($value)
    {
        do {
            if ($value instanceof \JsonSerializable) {
                $value = $value->jsonSerialize();
            } elseif ($value instanceof \Closure) {
                $value = $value();
            } else {
                break;
            }
        } while (true);

        return $value;
    }