/** * @param \Generated\Shared\Transfer\CategoryTransfer $category * @param \Generated\Shared\Transfer\LocaleTransfer $locale * * @return int */ public function create(CategoryTransfer $category, LocaleTransfer $locale) { $categoryEntity = new SpyCategory(); $categoryEntity->fromArray($category->toArray()); $categoryEntity->save(); $idCategory = $categoryEntity->getPrimaryKey(); $category->setIdCategory($idCategory); $this->persistCategoryAttribute($category, $locale); return $idCategory; }
/** * @param \Orm\Zed\Category\Persistence\SpyCategory $category * @param \Orm\Zed\Category\Persistence\SpyCategoryNode $node * * @return array */ protected function getBlockDataForView(SpyCategory $category, SpyCategoryNode $node) { $blockList = []; $blocks = $this->getFactory()->getCmsFacade()->getCmsBlocksByIdCategoryNode($node->getIdCategoryNode()); foreach ($blocks as $blockTransfer) { $blockData = $blockTransfer->toArray(); $blockData['view_node_name'] = 'child'; if ((int) $category->getIdCategory() === (int) $node->getFkCategory()) { $blockData['view_node_name'] = 'parent'; } $blockList[] = $blockData; } return $blockList; }
/** * @param \Orm\Zed\Category\Persistence\SpyCategory $categoryEntity * * @return \Generated\Shared\Transfer\CategoryTransfer */ public function convertCategory(SpyCategory $categoryEntity) { return (new CategoryTransfer())->fromArray($categoryEntity->toArray()); }
/** * @param \Orm\Zed\Category\Persistence\SpyCategory $categoryEntity * * @return string */ protected function getLocalizedCategoryName(SpyCategory $categoryEntity) { foreach ($categoryEntity->getAttributes() as $attributeEntity) { return $attributeEntity->getName(); } return self::UNKNOWN_CATEGORY; }