<?phpnamespace CoreBundle\Entity;use Doctrine\Common\Collections\ArrayCollection;use Application\Sonata\MediaBundle\Entity\Media;use Doctrine\Common\Collections\Collection;/** * BodyRepairCategory */class BodyRepairCategory{ /** * @var integer */ private $id; /** * @var boolean */ private $state; /** * @var string */ private $url; /** * @var integer */ private $position; /** * @var Media */ private $image; /** * @var Collection */ private $content; /** * @var Collection */ private $child_category; /** * @var \CoreBundle\Entity\BodyRepairCategory */ private $parent_category; /** * @var Collection */ private $repairs; /** * Constructor */ public function __construct() { $this->repairs = new ArrayCollection(); $this->content = new ArrayCollection(); $this->content->add((new BodyRepairCategoryContent())->setLanguage('ru')); $this->content->add((new BodyRepairCategoryContent())->setLanguage('ua')); $this->child_category = new ArrayCollection(); } /** * Get id * * @return integer */ public function getId() { return $this->id; } /** * Set state * * @param boolean $state * * @return BodyRepairCategory */ public function setState($state) { $this->state = $state; return $this; } /** * Get state * * @return boolean */ public function getState() { return $this->state; } /** * Set url * * @param string $url * * @return BodyRepairCategory */ public function setUrl($url) { $this->url = $url; return $this; } /** * Get url * * @return string */ public function getUrl() { return $this->url; } /** * Set position * * @param integer $position * * @return BodyRepairCategory */ public function setPosition($position) { $this->position = $position; return $this; } /** * Get position * * @return integer */ public function getPosition() { return $this->position; } /** * Set image * * @param Media $image * * @return BodyRepairCategory */ public function setImage(Media $image = null) { $this->image = $image; return $this; } /** * Get image * * @return Media */ public function getImage() { return $this->image; } /** * Add content * * @param BodyRepairCategoryContent $content * * @return BodyRepairCategory */ public function addContent(BodyRepairCategoryContent $content) { $this->content[] = $content; return $this; } /** * Remove content * * @param BodyRepairCategoryContent $content */ public function removeContent(BodyRepairCategoryContent $content) { $this->content->removeElement($content); } /** * Get content * * @return Collection */ public function getContent() { return $this->content; } /** * Add childCategory * * @param \CoreBundle\Entity\BodyRepairCategory $childCategory * * @return BodyRepairCategory */ public function addChildCategory(\CoreBundle\Entity\BodyRepairCategory $childCategory) { $this->child_category[] = $childCategory; return $this; } /** * Remove childCategory * * @param \CoreBundle\Entity\BodyRepairCategory $childCategory */ public function removeChildCategory(\CoreBundle\Entity\BodyRepairCategory $childCategory) { $this->child_category->removeElement($childCategory); } /** * Get childCategory * * @return Collection */ public function getChildCategory() { return $this->child_category; } /** * Set parentCategory * * @param \CoreBundle\Entity\BodyRepairCategory $parentCategory * * @return BodyRepairCategory */ public function setParentCategory(\CoreBundle\Entity\BodyRepairCategory $parentCategory = null) { $this->parent_category = $parentCategory; return $this; } /** * Get parentCategory * * @return \CoreBundle\Entity\BodyRepairCategory */ public function getParentCategory() { return $this->parent_category; } public function getNameCategory() { return $this->content->first() ? (string) $this->content->first()->getTitle() : ''; } public function __toString() { return $this->content->first() ? (string) $this->content->first()->getTitle() : ''; } /** * @param $locale * @return BodyRepairCategoryContent|false|string */ public function getContentByLocale($locale = null) { /** @var BodyRepairCategoryContent $content */ foreach ($this->content as $content) { if($content->getLanguage() == $locale) { return $content; } } return $this->content->first(); } /** * @var float */ private $price; /** * Set price * * @param float $price * * @return BodyRepairCategory */ public function setPrice($price) { $this->price = $price; return $this; } /** * Get price * * @return float */ public function getPrice() { return $this->price; }}