deblan.tv/vendor/trinity/src/Trinity/Bundle/MediaBundle/Model/Category.php
2015-03-02 21:57:49 +01:00

40 lines
941 B
PHP

<?php
namespace Trinity\Bundle\MediaBundle\Model;
use Trinity\Bundle\MediaBundle\Model\om\BaseCategory;
class Category extends BaseCategory
{
protected $category;
public function __toString()
{
return $this->getLabel();
}
public function getCategory()
{
if (null === $this->getCategoryId()) {
return null;
}
return $this->category ? $this->category : $this->category = CategoryQuery::create()->findOneById($this->getCategoryId());
}
public function save(\PropelPDO $con = null)
{
if ($this->getCategory()) {
if (!$this->isInTree()) {
$this->insertAsLastChildOf($this->getCategory());
} else {
if (!$this->isAncestorOf($this->getCategory())) {
$this->moveToLastChildOf($this->getCategory());
}
}
}
parent::save($con);
}
}