public function __construct(Text $text, Category $category, array $articles, $showArticleEditLinks, $showCategoryEditLinks) { parent::__construct($text); $this->category = $category; $this->editLinks = $showCategoryEditLinks; $this->articlesTemplate = new ArticleListTemplate($text, $articles, $category->getId(), true, true, $showArticleEditLinks); }
/** * Enloses the given HTML in an invisble link to the category. * @param Category $category Article to link to. * @param string $html HTML to enclose. * @return string The linked HTML. */ private function encloseInCategoryLink(Category $category, $html) { $text = $this->text; return <<<LINKED <a class="disguised_link" href="{$text->url("category", $category->getId())}"> {$html} </a> LINKED; }
/** * Deletes the given category. All articles are moved to the standard category. * @param ArticleRepository $articleRepo Repo for moving the articles. * @param Category $category The category that must be deleted. * @throws NotFoundException If this category doesn't exist in the database. * @throws PDOException If a database error occurs. * @throws InvalidArgumentException If the category is a standard category. */ public function deleteCategory(ArticleRepository $articleRepo, Category $category) { if ($category->isStandardCategory()) { throw new InvalidArgumentException("cannot delete standard category"); } $articleRepo->changeCategories($category->getId(), 1); $this->where($this->idField, '=', $category->getId())->deleteOneOrFail(); }