src/Sulu/Component/Media/SystemCollections/SystemCollectionManager.php
private function getOrCreateCollection($key, $localizedTitles, $userId, $parent)
    {
        $locales = array_keys($localizedTitles);
        $firstLocale = array_shift($locales);

        $collection = $this->collectionManager->getByKey($key, $firstLocale);
        if (null === $collection) {
            $collection = $this->createCollection($localizedTitles[$firstLocale], $key, $firstLocale, $userId, $parent);
        } else {
            $collection->setTitle($localizedTitles[$firstLocale]);
        }

        foreach ($locales as $locale) {
            $this->createCollection($localizedTitles[$locale], $key, $locale, $userId, $parent, $collection->getId());
        }

        return $collection;
    }
private function getOrCreateCollection($key, $localizedTitles, $userId, $parent)
    {
        $locales = array_keys($localizedTitles);
        $firstLocale = array_shift($locales);

        $collection = $this->collectionManager->getByKey($key, $firstLocale);
        if (null === $collection) {
            $collection = $this->createCollection($localizedTitles[$firstLocale], $key, $firstLocale, $userId, $parent);
        } else {
            $collection->setTitle($localizedTitles[$firstLocale]);
        }

        foreach ($locales as $locale) {
            $this->createCollection($localizedTitles[$locale], $key, $locale, $userId, $parent, $collection->getId());
        }

        return $collection;
    }
private function getOrCreateCollection ( $ key , $ localizedTitles , $ userId , $ parent ) { $ locales = array_keys ( $ localizedTitles ) ; $ firstLocale = array_shift ( $ locales ) ; $ collection = $ this -> collectionManager -> getByKey ( $ key , $ firstLocale ) ; if ( null === $ collection ) { $ collection = $ this -> createCollection ( $ localizedTitles [ $ firstLocale ] , $ key , $ firstLocale , $ userId , $ parent ) ; } else { $ collection -> setTitle ( $ localizedTitles [ $ firstLocale ] ) ; } foreach ( $ locales as $ locale ) { $ this -> createCollection ( $ localizedTitles [ $ locale ] , $ key , $ locale , $ userId , $ parent , $ collection -> getId ( ) ) ; } return $ collection ; }
Finds or create a new system-collection.

@param string $key
@param array $localizedTitles
@param int $userId
@param int|null $parent id of parent collection or null for root

@return Collection
Finds or create a new system - collection .