1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
<?php
/* --------------------------------------------------------------
StoredCategory.inc.php 2016-01-16
Gambio GmbH
http://www.gambio.de
Copyright (c) 2016 Gambio GmbH
Released under the GNU General Public License (Version 2)
[http://www.gnu.org/licenses/gpl-2.0.html]
--------------------------------------------------------------
*/
MainFactory::load_class('StoredCategoryInterface');
/**
* Class StoredCategory
*
* This class extends the Category class and represents a persisted category with an unique ID.
*
* @category System
* @package Category
* @subpackage Entities
*/
class StoredCategory extends Category implements StoredCategoryInterface
{
/**
* Category ID.
*
* @var int
*/
protected $categoryId = 0;
/**
* Class Constructor
*
* @param IdType $categoryId Category ID.
* @param CategorySettingsInterface $settings Category settings.
*/
public function __construct(IdType $categoryId, CategorySettingsInterface $settings)
{
parent::__construct($settings);
$this->categoryId = $categoryId->asInt();
}
/**
* Gets the ID of the StoredCategory.
*
* @return int
*/
public function getCategoryId()
{
return $this->categoryId;
}
/**
* Get the addon value container ID.
*
* @return int
*/
public function getAddonValueContainerId()
{
return $this->getCategoryId();
}
/**
* Sets the parent ID of the category.
*
* @param IdType $categoryId The parent ID.
*
* @throws LogicException When the passed id is equal to the category id.
*
* @return StoredCategory|$this Same instance for chained method calls.
*/
public function setParentId(IdType $categoryId)
{
$id = $categoryId->asInt();
if($this->getCategoryId() === $id)
{
throw new LogicException('The parent id can not be equal to the category id "' . $id . '"');
}
parent::setParentId($categoryId);
}
}