40 lines
941 B
Plaintext
40 lines
941 B
Plaintext
<?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);
|
|
}
|
|
}
|