Exemplo n.º 1
0
 /**
  * @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;
 }
Exemplo n.º 2
0
 /**
  * @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;
 }
Exemplo n.º 3
0
 /**
  * @param \Orm\Zed\Category\Persistence\SpyCategory $categoryEntity
  *
  * @return \Generated\Shared\Transfer\CategoryTransfer
  */
 public function convertCategory(SpyCategory $categoryEntity)
 {
     return (new CategoryTransfer())->fromArray($categoryEntity->toArray());
 }
Exemplo n.º 4
0
 /**
  * @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;
 }