<?phpnamespace CoreBundle\Entity;use Doctrine\Common\Collections\ArrayCollection;use Application\Sonata\MediaBundle\Entity\Media;use DcSiteBundle\Entity\Job;use Doctrine\Common\Collections\Collection;use DcSiteBundle\Entity\PageContent;/** * ServicePage */class ServicePage{ /** * @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 string */ private $uid_1c; /** * @var Dealer */ private $dealer; /** * @var Collection */ private $jobs; /** * Constructor */ public function __construct() { $this->content = new ArrayCollection(); $this->content->add((new ServicePageContent())->setLanguage('ru')); $this->content->add((new ServicePageContent())->setLanguage('ua')); } /** * Get id * * @return integer */ public function getId() { return $this->id; } /** * Get title * * @return string */ public function getTitle() { return $this->getContentByLocale()->getTitle(); } /** * Set state * * @param boolean $state * * @return ServicePage */ 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 ServicePage */ 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 ServicePage */ 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 ServicePage */ public function setImage(Media $image = null) { $this->image = $image; return $this; } /** * Get image * * @return Media */ public function getImage() { return $this->image; } /** * Add content * * @param ServicePageContent $content * * @return ServicePage */ public function addContent(ServicePageContent $content) { $this->content[] = $content; return $this; } /** * Remove content * * @param ServicePageContent $content */ public function removeContent(ServicePageContent $content) { $this->content->removeElement($content); } /** * Get content * * @return Collection */ public function getContent() { return $this->content; } /** * @var Collection */ private $categories; /** * Add page * * @param ServicePageCategory $category * * @return ServicePage */ public function addCategory(ServicePageCategory $category) { $this->categories[] = $category; return $this; } /** * Remove page * * @param ServicePageCategory $category */ public function removeCategory(ServicePageCategory $category) { $this->categories->removeElement($category); } /** * Set category * * @param ServicePageCategory $category * * @return ServicePageCategory */ public function setCategories(ServicePageCategory $category = null) { $this->category = $category; return $this; } /** * Get category * * @return Collection */ public function getCategories() { return $this->categories; } /** * Set uid1c * * @param string $uid1c * * @return ServicePage */ public function setUid1c($uid1c) { $this->uid_1c = $uid1c; return $this; } /** * Get uid1c * * @return string */ public function getUid1c() { return $this->uid_1c; } /** * Set dealer * * @param Dealer $dealer * * @return ServicePage */ public function setDealer(Dealer $dealer = null) { $this->dealer = $dealer; return $this; } /** * Get dealer * * @return Dealer */ public function getDealer() { return $this->dealer; } public function __toString() { return $this->content->first() ? (string) $this->content->first()->getTitle() : ''; } public function getContentByLocale($locale = 'ru') { /** @var ServicePageContent $content */ foreach ($this->content as $content) { if($content->getLanguage() == $locale) { return $content; } } return $this->content->first(); } /** * Add job * * @param Job $job * * @return ServicePage */ public function addJob(Job $job) { $this->jobs[] = $job; return $this; } /** * Remove job * * @param Job $job */ public function removeJob(Job $job) { $this->jobs->removeElement($job); } /** * Get jobs * * @return Collection */ public function getJobs() { return $this->jobs; }}