@param Collection $blockCollection
@param array      $params

@return FacadeInterface
186151
public function transform($blockCollection, array $params = array())
    {
        $facade = $this->newFacade();

        foreach ($blockCollection as $block) {
            $facade->addBlock($this->getContext()->transform('block', $block));
        }

        return $facade;
    }
1177761
private function trackBlocks(Collection $collection, array $blocks)
    {
        $this->trackTrackables(
            $collection,
            $this->getTrackables($blocks, function ($block) {
                if ($block instanceof Block) {
                    return $block->getController();
                }

                return $block;
            }),
            function (Collection $collection, BlockController $controller, $fileId) {
                $this->persist(
                    $fileId,
                    $collection->getCollectionID(),
                    $collection->getVersionID(),
                    $controller->getBlockObject()->getBlockID());
                return true;
            });
    }
838002
private function visitCollections(Block $block, VisitorInterface $subVisitor): Generator
    {
        foreach ($block->getCollections() as $identifier => $collection) {
            yield $identifier => $subVisitor->visit($collection);
        }
    }
317358
private function mergeSettings(Collection $remotes, Collection $locals): ArrayCollection
    {
        $settings = $remotes->toArray();

        /** @var SettingInterface $local */
        foreach ($locals->toArray() as $local) {
            if (!$this->exists($remotes, $local)) {
                $settings[] = $local;
            }
        }

        return new ArrayCollection($settings);
    }
1091225
private function trackCollection(Collection $collection)
    {
        $blocks = $collection->getBlocks();
        $this->trackBlocks($collection, $blocks);

        $attributes = $collection->getSetCollectionAttributes();
        $this->trackAttributes($collection, $attributes);
    }
33285
private function deleteBlockCollections(array $blockIds, ?int $status = null): void
    {
        $collectionIds = $this->queryHandler->loadBlockCollectionIds($blockIds, $status);
        foreach ($collectionIds as $collectionId) {
            $this->collectionHandler->deleteCollection($collectionId, $status);
        }

        $this->queryHandler->deleteCollectionReferences($blockIds, $status);
    }
73054
private function trackCollection(Collection $collection)
    {
        $blocks = $collection->getBlocks();
        $this->trackBlocks($collection, $blocks);
    }
1221417
public function merge(CollectionInterface ...$collections): CollectionInterface
    {
        $temp = [$this->data];

        foreach ($collections as $index => $collection) {
            if (!$collection instanceof static) {
                throw new CollectionMismatchException(
                    \sprintf('Collection with index %d must be of type %s', $index, static::class)
                );
            }

            $temp[] = $collection->toArray();
        }

        return new static(\array_merge(...$temp));
    }
1282259
public function merge(ArrayCollection $collection)
    {
        if (!$collection instanceof GeometryCollection || $collection->getGeometryType() !== $this->getGeometryType()) {
            throw new InvalidArgumentException("Collections types don't match, you can't merge.");
        }

        return parent::merge($collection);
    }
898930
public function transform($siteCollection, array $params = array())
    {
        $facade = $this->newFacade();

        foreach ($siteCollection as $site) {
            $facade->addSite($this->getContext()->transform('site', $site));
        }

        return $facade;
    }
945429
private function copyBlockCollections(Block $block, Block $targetBlock): void
    {
        $collectionReferences = $this->loadCollectionReferences($block);

        foreach ($collectionReferences as $collectionReference) {
            $collection = $this->collectionHandler->loadCollection(
                $collectionReference->collectionId,
                $collectionReference->collectionStatus
            );

            $collection = $this->collectionHandler->copyCollection($collection);

            $newCollectionReference = CollectionReference::fromArray(
                [
                    'blockId' => $targetBlock->id,
                    'blockStatus' => $targetBlock->status,
                    'collectionId' => $collection->id,
                    'collectionStatus' => $collection->status,
                    'identifier' => $collectionReference->identifier,
                ]
            );

            $this->queryHandler->createCollectionReference($newCollectionReference);
        }
    }
532681
private static function parseParameters(array $parametersArray): ParameterCollectionInterface
    {
        $parameters = new ParameterCollection();

        foreach ($parametersArray as $parameterName => $parameterValue) {
            $parameters->set(
                strval($parameterName),
                strval(is_array($parameterValue) ? $parameterValue[0] : $parameterValue)
            );
        }

        return $parameters;
    }
5795
public function transform($contentCollection, array $params = array())
    {
        $facade = $this->newFacade();

        foreach ($contentCollection as $content) {
            $facade->addContent($this->getContext()->transform('content', $content));
        }

        return $facade;
    }
125804
public function execute(BlockInterface $block, Response $response = null, array $parameters = [])
    {
        $collection = $this->contentManager->getRepository()->findOrderedByIds(json_decode($block->getValue()));

        if ($collection) {
            $block->setCollection($collection);
        }

        return parent::execute($block, $response, $parameters);
    }
1080582
public static function addLocaleToCollection(Collection $collection, LocaleInterface $locale)
    {
        $exist = $collection->exists(function ($key, LocaleInterface $el) use ($locale) {
            return $el->isLocale($locale->getLocale());
        });
        if (!$exist) {
            $collection->add($locale);
        }

        return $collection;
    }
199917
public function transform($keywordCollection, array $params = array())
    {
        $facade = $this->newFacade();

        foreach ($keywordCollection as $keyword) {
            $facade->addKeyword($this->getContext()->transform('keyword', $keyword));
        }

        return $facade;
    }
308227
private function createParamsArrayByParamsCollection(ConnectionConfigParamCollectionInterface $paramsCollection)
    {
        $params = [];

        foreach ($paramsCollection as $param) {
            $params[(string)$param->getName()] = (string)$param->getValue();
        }

        return $params;
    }