/** * Adds category to the list of this news item categories. * * @param kyNewsCategory $category News category. * @param bool $clear Clear the list before adding. * @return kyNewsItem */ public function addCategory(kyNewsCategory $category, $clear = false) { if ($clear) { $this->categories = array(); $this->category_ids = array(); } if (!in_array($category->getId(), $this->category_ids)) { $this->category_ids[] = $category->getId(); $this->categories[$category->getId()] = $category; } return $this; }