示例#1
0
 /**
  * @param \Generated\Shared\Transfer\CategoryTransfer $category
  * @param \Generated\Shared\Transfer\LocaleTransfer $locale
  * @param \Orm\Zed\Category\Persistence\SpyCategoryAttribute $categoryAttributeEntity
  *
  * @return void
  */
 protected function saveCategoryAttribute(CategoryTransfer $category, LocaleTransfer $locale, SpyCategoryAttribute $categoryAttributeEntity)
 {
     $categoryAttributeEntity->fromArray($category->toArray());
     $categoryAttributeEntity->setFkCategory($category->getIdCategory());
     $categoryAttributeEntity->setFkLocale($locale->getIdLocale());
     $categoryAttributeEntity->save();
 }
 /**
  * @param string $name
  * @param \Generated\Shared\Transfer\LocaleTransfer $locale
  *
  * @return array
  */
 protected function createDummyRootCategoryWithNode($name, $locale)
 {
     $parentCategory1 = new CategoryTransfer();
     $parentCategory1->setName($name);
     $parentCategory1->setCategoryKey(strtolower($name));
     $idCategory = $this->categoryFacade->createCategory($parentCategory1, $locale);
     $categoryNodeTransfer = new NodeTransfer();
     $categoryNodeTransfer->setFkCategory($idCategory);
     $categoryNodeTransfer->setIsRoot(true);
     $idNode = $this->categoryFacade->createCategoryNode($categoryNodeTransfer, $locale, false);
     return [$idCategory, $idNode];
 }
 /**
  * @param \Generated\Shared\Transfer\CategoryTransfer $categoryTransfer
  * @param \Generated\Shared\Transfer\LocaleTransfer $locale
  * @param array $data
  *
  * @return \Generated\Shared\Transfer\NodeTransfer
  */
 protected function updateCategoryNodeChild(CategoryTransfer $categoryTransfer, LocaleTransfer $locale, array $data)
 {
     $nodeTransfer = $this->createCategoryNodeTransferFromData($data);
     $nodeTransfer->setIsMain(false);
     $existingCategoryNode = $this->getFactory()->getCategoryQueryContainer()->queryNodeByIdCategoryAndParentNode($categoryTransfer->getIdCategory(), $nodeTransfer->getFkParentCategoryNode())->findOne();
     $this->createOrUpdateCategoryNode($existingCategoryNode, $nodeTransfer, $locale);
     return $nodeTransfer;
 }
示例#4
0
 /**
  * @param string $categoryKey
  * @param int $idLocale
  *
  * @return \Generated\Shared\Transfer\CategoryTransfer
  */
 public function getCategoryByKey($categoryKey, $idLocale)
 {
     $categoryQuery = $this->queryContainer->queryByCategoryKey($categoryKey, $idLocale);
     $entity = $categoryQuery->findOne();
     $transfer = new CategoryTransfer();
     $transfer->fromArray($entity->toArray());
     return $transfer;
 }
 /**
  * @param \Generated\Shared\Transfer\CategoryTransfer $categoryTransfer
  * @param \Generated\Shared\Transfer\NodeTransfer $categoryNodeTransfer
  * @param \Generated\Shared\Transfer\LocaleTransfer $localeTransfer
  *
  * @return int
  */
 public function addCategory(CategoryTransfer $categoryTransfer, NodeTransfer $categoryNodeTransfer, LocaleTransfer $localeTransfer)
 {
     $this->connection->beginTransaction();
     $categoryTransfer->setIsActive(true);
     $categoryTransfer->setIsInMenu(true);
     $categoryTransfer->setIsClickable(true);
     $idCategory = $this->categoryFacade->createCategory($categoryTransfer, $localeTransfer);
     $categoryNodeTransfer->setFkCategory($idCategory);
     $categoryNodeTransfer->setIsMain(true);
     $this->categoryFacade->createCategoryNode($categoryNodeTransfer, $localeTransfer);
     $this->connection->commit();
     return $idCategory;
 }