/** * @param CreateCategoryRequest $request */ public function execute(CreateCategoryRequest $request) { $category = $this->categoryFactory->create($request->getName()); $this->categoryRepository->add($category); $this->treeManager->assignParent($category, $request->getParent()); $this->categoryCreated(); }
/** * @Given I create root category :arg1 */ public function iCreateRootCategory($arg1) { $rootCategory = $this->categoryRepository->findRootCategory(); if ($rootCategory) { throw new \Exception('Root category exist with name ', $rootCategory->getName()); } $category = new Category($arg1, true); $this->categoryRepository->add($category); }
/** * @Given there are such categories: */ public function thereAreSuchCategories(TableNode $table) { foreach ($table as $row) { $name = $row['name']; $parentName = $row['parent']; $parent = $this->getCategoryFromListByName($parentName); $category = new Category($name); $this->categoryRepository->add($category); $parent->addChild($category); $this->categoryRepository->update($parent); } }