예제 #1
0
 /**
  * @inheritdoc
  */
 function create($args)
 {
     $category = new Category();
     $category->setName($args['name']);
     $category->setCollection($this->getCollection($args['collection']));
     $category->setPicture($this->createImage($args['picture']));
     return $category;
 }
예제 #2
0
 protected function setCollection(Category $category)
 {
     if ($category->getCollection() instanceof CollectionInterface) {
         return;
         //do nothing if collection is already set
     }
     $collectionName = $this->container->getParameter('enhavo_category.default_collection');
     $collection = $this->container->get('enhavo_category.repository.collection')->findOneBy(['name' => $collectionName]);
     if ($collection === null) {
         $collection = new Collection();
         $collection->setName($collectionName);
         $this->container->get('doctrine.orm.entity_manager')->persist($collection);
     }
     $category->setCollection($collection);
 }
예제 #3
0
 /**
  * Remove categories
  *
  * @param \Enhavo\Bundle\CategoryBundle\Entity\Category $categories
  */
 public function removeCategory(\Enhavo\Bundle\CategoryBundle\Entity\Category $category)
 {
     $category->setCollection(null);
     $this->categories->removeElement($category);
 }