/** * Removes a category by its associated id * * @param string $id Category's id * @return boolean */ public function deleteById($id) { // Grab category's name before we remove it $title = Filter::escape($this->categoryMapper->fetchNameById($id)); // Completely remove the post $this->removeChildCategoriesByParentId($id); $this->removeAllById($id); $this->track('Category "%s" has been removed', $title); return true; }
/** * {@inheritDoc} */ protected function toEntity(array $post) { $entity = new PostEntity(); $entity->setId($post['id'], PostEntity::FILTER_INT)->setLangId($post['lang_id'], PostEntity::FILTER_INT)->setWebPageId($post['web_page_id'], PostEntity::FILTER_INT)->setCategoryTitle($this->categoryMapper->fetchNameById($post['category_id']), PostEntity::FILTER_HTML)->setTitle($post['title'], PostEntity::FILTER_HTML)->setName($post['name'], PostEntity::FILTER_HTML)->setCategoryId($post['category_id'], PostEntity::FILTER_INT)->setIntroduction($post['introduction'], PostEntity::FILTER_SAFE_TAGS)->setFull($post['full'], PostEntity::FILTER_SAFE_TAGS)->setTimestamp($post['timestamp'], PostEntity::FILTER_INT)->setPublished($post['published'], PostEntity::FILTER_BOOL)->setComments($post['comments'], PostEntity::FILTER_BOOL)->setSeo($post['seo'], PostEntity::FILTER_BOOL)->setSlug($this->webPageManager->fetchSlugByWebPageId($post['web_page_id']))->setKeywords($post['keywords'], PostEntity::FILTER_HTML)->setMetaDescription($post['meta_description'], PostEntity::FILTER_HTML)->setDate(date($this->getTimeFormat(), $entity->getTimestamp()))->setPermanentUrl('/module/blog/post/' . $entity->getId())->setUrl($this->webPageManager->surround($entity->getSlug(), $entity->getLangId()))->setViewsCount($post['views'], PostEntity::FILTER_INT); return $entity; }