/** * Adds an item from a widget * This method usually invoked from within another module services * * @param array $input * @param string $webPageId * @param string $name * @return boolean */ public function add(array $input, $webPageId, $name) { $items = $this->normalizeInput($input); foreach ($items as $item) { $item = $this->prepareItem($item, $webPageId, $name); $this->itemMapper->insert($item); } return true; }
/** * Renders category block associated with provided web page id * * @param string $webPageId * @return string The block */ public function renderByAssocWebPageId($webPageId) { $categoryId = $this->itemMapper->fetchCategoryIdByWebPageId($webPageId); $class = $this->categoryMapper->fetchClassById($categoryId); return $this->renderByClass($class, $webPageId); }
/** * Fetches item's entity by its associated id * * @param string $id * @return \Krystal\Stdlib\VirtualEntity */ public function fetchById($id) { return $this->prepareResult($this->itemMapper->fetchById($id)); }
/** * Deletes a category by its associated id * Also remove items associated with given category id * * @param string $id * @return boolean Depending on success */ public function deleteById($id) { $name = Filter::escape($this->categoryMapper->fetchNameById($id)); $this->track('Category menu "%s" has been removed', $name); return $this->categoryMapper->deleteById($id) && $this->itemMapper->deleteAllByCategoryId($id); }