Пример #1
0
 /**
  * @param \Generated\Shared\Transfer\NodeTransfer $categoryNode
  *
  * @return void
  */
 public function update(NodeTransfer $categoryNode)
 {
     $nodeEntity = $this->queryContainer->queryNodeById($categoryNode->getIdCategoryNode())->findOne();
     if ($nodeEntity) {
         $nodeEntity->fromArray($categoryNode->toArray());
         $nodeEntity->save();
     }
 }
Пример #2
0
 /**
  * @param \Generated\Shared\Transfer\NodeTransfer $categoryNode
  *
  * @return void
  */
 protected function createRootNode(NodeTransfer $categoryNode)
 {
     $nodeId = $categoryNode->getIdCategoryNode();
     $pathEntity = new SpyCategoryClosureTable();
     $pathEntity->setFkCategoryNode($nodeId);
     $pathEntity->setFkCategoryNodeDescendant($nodeId);
     $pathEntity->setDepth(0);
     $pathEntity->save();
 }
Пример #3
0
 /**
  * @param \Orm\Zed\Category\Persistence\SpyCategoryNode $existingCategoryNode
  * @param \Generated\Shared\Transfer\NodeTransfer $categoryNodeTransfer
  * @param \Generated\Shared\Transfer\LocaleTransfer $locale
  *
  * @return void
  */
 protected function createOrUpdateCategoryNode($existingCategoryNode, NodeTransfer $categoryNodeTransfer, LocaleTransfer $locale)
 {
     /** @var \Orm\Zed\Category\Persistence\SpyCategoryNode $existingCategoryNode */
     if ($existingCategoryNode) {
         $categoryNodeTransfer->setIdCategoryNode($existingCategoryNode->getIdCategoryNode());
         $this->getFactory()->getCategoryFacade()->updateCategoryNode($categoryNodeTransfer, $locale);
     } else {
         $newData = $categoryNodeTransfer->toArray();
         unset($newData['id_category_node']);
         $categoryNodeTransfer = $this->createCategoryNodeTransferFromData($newData);
         $this->getFactory()->getCategoryFacade()->createCategoryNode($categoryNodeTransfer, $locale);
     }
 }
Пример #4
0
 /**
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 public function reorderAction(Request $request)
 {
     $locale = $this->getFactory()->getCurrentLocale();
     $categoryNodesToReorder = (array) json_decode($request->request->get('nodes'), true);
     $order = count($categoryNodesToReorder) - 1;
     foreach ($categoryNodesToReorder as $index => $nodeData) {
         $idNode = $nodeData['id'];
         $nodeEntity = $this->getQueryContainer()->queryNodeById($idNode)->findOne();
         $nodeTransfer = new NodeTransfer();
         $nodeTransfer->fromArray($nodeEntity->toArray());
         $nodeTransfer->setNodeOrder($order);
         $this->getFacade()->updateCategoryNode($nodeTransfer, $locale);
         $order--;
     }
     return $this->jsonResponse(['code' => Response::HTTP_OK, 'message' => 'Category nodes successfully reordered']);
 }
 /**
  * @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];
 }
Пример #6
0
 /**
  * @param \Generated\Shared\Transfer\NodeTransfer $categoryNodeTransfer
  *
  * @return void
  */
 public function removeUrl(NodeTransfer $categoryNodeTransfer)
 {
     $idNode = $categoryNodeTransfer->getIdCategoryNode();
     $urls = $this->urlFacade->getResourceUrlCollectionByCategoryNodeId($idNode);
     foreach ($urls as $urlTransfer) {
         $this->urlFacade->deleteUrl($urlTransfer);
     }
 }
Пример #7
0
 /**
  * @param \Generated\Shared\Transfer\NodeTransfer $categoryNode
  *
  * @return void
  */
 protected function touchCategoryDeletedRecursive(NodeTransfer $categoryNode)
 {
     $closureQuery = new SpyCategoryClosureTableQuery();
     $nodes = $closureQuery->findByFkCategoryNode($categoryNode->getIdCategoryNode());
     foreach ($nodes as $node) {
         $this->touchCategoryDeleted($node->getFkCategoryNodeDescendant());
     }
     $this->touchCategoryDeleted($categoryNode->getIdCategoryNode());
 }
 /**
  * @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;
 }