setLocale() публичный Метод

Set locale.
public setLocale ( string $locale ) : CollectionMeta
$locale string
Результат CollectionMeta
Пример #1
0
 protected function setUpCollection()
 {
     $this->collection = new Collection();
     $style = ['type' => 'circle', 'color' => '#ffcc00'];
     $this->collection->setStyle(json_encode($style));
     // Create Collection Type
     $this->collectionType = new CollectionType();
     $this->collectionType->setName('Default Collection Type');
     $this->collectionType->setDescription('Default Collection Type');
     $this->collection->setType($this->collectionType);
     // Collection Meta 1
     $this->collectionMeta = new CollectionMeta();
     $this->collectionMeta->setTitle('Test Collection');
     $this->collectionMeta->setDescription('This Description is only for testing');
     $this->collectionMeta->setLocale('en-gb');
     $this->collectionMeta->setCollection($this->collection);
     $this->collection->addMeta($this->collectionMeta);
     // Collection Meta 2
     $collectionMeta2 = new CollectionMeta();
     $collectionMeta2->setTitle('Test Kollektion');
     $collectionMeta2->setDescription('Dies ist eine Test Beschreibung');
     $collectionMeta2->setLocale('de');
     $collectionMeta2->setCollection($this->collection);
     $this->collection->addMeta($collectionMeta2);
     $this->em->persist($this->collection);
     $this->em->persist($this->collectionType);
     $this->em->persist($this->collectionMeta);
     $this->em->persist($collectionMeta2);
 }
Пример #2
0
 private function createCollection($typeName, $title = [], $parent = null)
 {
     // Collection
     $collection = new Collection();
     $style = ['type' => 'circle', 'color' => '#ffcc00'];
     $collection->setStyle(json_encode($style));
     // Create Collection Type
     $collectionType = new CollectionType();
     $collectionType->setName($typeName);
     $collectionType->setDescription('Default Collection Type');
     $collection->setType($collectionType);
     // Collection Meta 1
     $collectionMeta = new CollectionMeta();
     $collectionMeta->setTitle(isset($title['en-gb']) ? $title['en-gb'] : 'Collection');
     $collectionMeta->setDescription('This Description is only for testing');
     $collectionMeta->setLocale('en-gb');
     $collectionMeta->setCollection($collection);
     $collection->setDefaultMeta($collectionMeta);
     $collection->addMeta($collectionMeta);
     // Collection Meta 2
     $collectionMeta2 = new CollectionMeta();
     $collectionMeta2->setTitle(isset($title['de']) ? $title['de'] : 'Kollection');
     $collectionMeta2->setDescription('Dies ist eine Test Beschreibung');
     $collectionMeta2->setLocale('de');
     $collectionMeta2->setCollection($collection);
     $collection->addMeta($collectionMeta2);
     $collection->setParent($parent);
     $this->em->persist($collection);
     $this->em->persist($collectionType);
     $this->em->persist($collectionMeta);
     $this->em->persist($collectionMeta2);
     $this->em->flush();
     return $collection;
 }
 private function createCollection($name, $parent, $collectionType)
 {
     $collection = new Collection();
     $collectionMeta = new CollectionMeta();
     $collectionMeta->setTitle($name);
     $collectionMeta->setLocale('en-gb');
     $collection->setType($collectionType);
     $collectionMeta->setCollection($collection);
     $collection->addMeta($collectionMeta);
     if ($parent !== null) {
         $collection->setParent($this->collections[$parent]);
         $this->collections[$parent]->addChildren($collection);
     }
     $this->em->persist($collection);
     $this->em->persist($collectionMeta);
     return $collection;
 }
Пример #4
0
 /**
  * Get or create a media collection.
  *
  * @param string $name Name of collection to get or create
  *
  * @return Collection
  */
 private function getOrCreateMediaCollection($name)
 {
     $manager = $this->getEntityManager();
     $collectionMeta = $manager->getRepository('SuluMediaBundle:CollectionMeta')->findOneByTitle($name);
     if ($collectionMeta) {
         return $collectionMeta->getCollection();
     }
     $collection = new Collection();
     $collection->setType($this->getOrCreateCollectionType('Default'));
     $collectionMeta = new CollectionMeta();
     $collectionMeta->setTitle($name);
     $collectionMeta->setDescription('Dies ist eine Test Beschreibung');
     $collectionMeta->setLocale('en');
     $collectionMeta->setCollection($collection);
     $collection->addMeta($collectionMeta);
     $manager->persist($collection);
     $manager->persist($collectionMeta);
     $manager->flush();
     $this->lastCollection = $collection;
     return $collection;
 }
Пример #5
0
 /**
  * @param bool $create
  *
  * @return CollectionMeta
  */
 private function getMeta($create = false)
 {
     $locale = $this->locale;
     $metaCollection = $this->entity->getMeta();
     // get meta only with this locale
     $metaCollectionFiltered = $metaCollection->filter(function ($meta) use($locale) {
         /** @var CollectionMeta $meta */
         if ($meta->getLocale() == $locale) {
             return true;
         }
         return false;
     });
     // check if meta was found
     if ($metaCollectionFiltered->isEmpty()) {
         if ($create) {
             // create when not found
             $meta = new CollectionMeta();
             $meta->setLocale($this->locale);
             $meta->setCollection($this->entity);
             $this->entity->addMeta($meta);
             return $meta;
         }
         // return first when create false
         return $this->entity->getDefaultMeta();
     }
     // return exists
     return $metaCollectionFiltered->first();
 }
 private function createCollection($name, $parent = null)
 {
     $collection = new Collection();
     $collectionType = new CollectionType();
     $collectionType->setName($name);
     $collectionType->setDescription('Default Collection Type');
     $collectionMeta = new CollectionMeta();
     $collectionMeta->setTitle('Test Collection');
     $collectionMeta->setDescription('This Description is only for testing');
     $collectionMeta->setLocale('en-gb');
     $collection->setType($collectionType);
     $collectionMeta->setCollection($collection);
     $collection->addMeta($collectionMeta);
     if ($parent !== null) {
         $collection->setParent($this->collections[$parent]);
         $this->collections[$parent]->addChildren($collection);
     }
     $this->em->persist($collection);
     $this->em->persist($collectionMeta);
     $this->em->persist($collectionType);
     return $collection;
 }