<?phpnamespace DcSiteBundle\Entity;use Doctrine\Common\Collections\ArrayCollection;use Application\Sonata\MediaBundle\Entity\Media;use Doctrine\Common\Collections\Collection;/** * AccessoriesCategory */class AccessoriesCategory{ /** * @var integer */ private $id; /** * @var boolean */ private $state; /** * @var string */ private $url; /** * @var integer */ private $position; /** * @var Media */ private $image; /** * @var Collection */ private $accessory_items; /** * @var Collection */ private $content; /** * @var Collection */ private $child_category; /** * @var \DcSiteBundle\Entity\AccessoriesCategory */ private $parent_category; /** * Constructor */ public function __construct() { $this->accessory_items = new ArrayCollection(); $this->content = new ArrayCollection(); $this->content->add((new AccessoriesCategoryContent())->setLanguage('ru')); $this->content->add((new AccessoriesCategoryContent())->setLanguage('ua')); $this->child_category = new ArrayCollection(); } /** * Get id * * @return integer */ public function getId() { return $this->id; } /** * Set state * * @param boolean $state * * @return AccessoriesCategory */ 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 AccessoriesCategory */ 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 AccessoriesCategory */ 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 AccessoriesCategory */ public function setImage(Media $image = null) { $this->image = $image; return $this; } /** * Get image * * @return Media */ public function getImage() { return $this->image; } /** * Add accessoryItem * * @param Accessories $accessoryItem * * @return AccessoriesCategory */ public function addAccessoryItem(Accessories $accessoryItem) { $this->accessory_items[] = $accessoryItem; return $this; } /** * Remove accessoryItem * * @param Accessories $accessoryItem */ public function removeAccessoryItem(Accessories $accessoryItem) { $this->accessory_items->removeElement($accessoryItem); } /** * Get accessoryItems * * @return Collection */ public function getAccessoryItems() { return $this->accessory_items; } /** * Add content * * @param AccessoriesCategoryContent $content * * @return AccessoriesCategory */ public function addContent(AccessoriesCategoryContent $content) { $this->content[] = $content; return $this; } /** * Remove content * * @param AccessoriesCategoryContent $content */ public function removeContent(AccessoriesCategoryContent $content) { $this->content->removeElement($content); } /** * Get content * * @return Collection */ public function getContent() { return $this->content; } /** * Add childCategory * * @param \DcSiteBundle\Entity\AccessoriesCategory $childCategory * * @return AccessoriesCategory */ public function addChildCategory(\DcSiteBundle\Entity\AccessoriesCategory $childCategory) { $this->child_category[] = $childCategory; return $this; } /** * Remove childCategory * * @param \DcSiteBundle\Entity\AccessoriesCategory $childCategory */ public function removeChildCategory(\DcSiteBundle\Entity\AccessoriesCategory $childCategory) { $this->child_category->removeElement($childCategory); } /** * Get childCategory * * @return Collection */ public function getChildCategory() { return $this->child_category; } /** * Set parentCategory * * @param \DcSiteBundle\Entity\AccessoriesCategory $parentCategory * * @return AccessoriesCategory */ public function setParentCategory(\DcSiteBundle\Entity\AccessoriesCategory $parentCategory = null) { $this->parent_category = $parentCategory; return $this; } /** * Get parentCategory * * @return \DcSiteBundle\Entity\AccessoriesCategory */ public function getParentCategory() { return $this->parent_category; } public function getNameCategory() { return $this->content->first() ? (string) $this->content->first()->getNameCategory() : ''; } public function __toString() { return $this->content->first() ? (string) $this->content->first()->getNameCategory() : ''; } public function getContentByLocale($locale = null) { /** @var AccessoriesCategoryContent $content */ foreach ($this->content as $content) { if($content->getLanguage() == $locale) { return $content; } } return $this->content->first(); }}