public function reverseTransform($values)
    {
        $collection = new ArrayCollection();

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

        if (!is_array($values)) {
            throw new UnexpectedTypeException($values, 'array');
        }
        $values = Util::filterScalarValues($values);

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

        try {
            $hash = $this->getCacheHash($values);
            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, $values) as $entity) {
                    $collection->add($entity);
                }
                $this->cachedResults[$hash] = $collection; //Saves result in cache
            }
        } catch (\Exception $e) {
            throw new TransformationFailedException('Tranformation: Query Error');
        }

        return $collection;
    }
public function reverseTransform($values)
    {
        $collection = new ArrayCollection();

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

        if (!is_array($values)) {
            throw new UnexpectedTypeException($values, 'array');
        }
        $values = Util::filterScalarValues($values);

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

        try {
            $hash = $this->getCacheHash($values);
            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, $values) as $entity) {
                    $collection->add($entity);
                }
                $this->cachedResults[$hash] = $collection; //Saves result in cache
            }
        } catch (\Exception $e) {
            throw new TransformationFailedException('Tranformation: Query Error');
        }

        return $collection;
    }
public function reverseTransform ( $ values ) { $ collection = new ArrayCollection ( ) ; if ( '' === $ values || null === $ values ) { return $ collection ; } if ( ! is_array ( $ values ) ) { throw new UnexpectedTypeException ( $ values , 'array' ) ; } $ values = Util :: filterScalarValues ( $ values ) ; if ( count ( $ values ) == 0 ) { return $ collection ; } $ values = \ array_unique ( $ values ) ; if ( count ( $ values ) > $ this -> maxResults ) { throw new TransformationFailedException ( sprintf ( 'This collection should contain %s elements or less.' , $ this -> maxResults ) ) ; } try { $ hash = $ this -> getCacheHash ( $ values ) ; 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 , $ values ) as $ entity ) { $ collection -> add ( $ entity ) ; } $ this -> cachedResults [ $ hash ] = $ collection ; //Saves result in cache } } catch ( \ Exception $ e ) { throw new TransformationFailedException ( 'Tranformation: Query Error' ) ; } return $ collection ; }
Transforms ids array to Collection entities
@param array $values
@return Collection
Transforms ids array to Collection entities