src/Aqarmap/Bundle/ListingBundle/Entity/Section.php line 28
<?phpnamespace Aqarmap\Bundle\ListingBundle\Entity;use Aqarmap\Bundle\ExchangeBundle\Entity\ExchangeRequest;use Aqarmap\Bundle\ListingBundle\Constant\ListingStatus;use Aqarmap\Bundle\UserBundle\Entity\UserInterest;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Criteria;use Doctrine\ORM\Mapping as ORM;use Gedmo\Mapping\Annotation as Gedmo;use Gedmo\Translatable\Translatable;use JMS\Serializer\Annotation as Serializer;/*** Section.*/#[ORM\Cache]#[ORM\Entity(repositoryClass: \Aqarmap\Bundle\ListingBundle\Repository\SectionRepository::class)]#[ORM\Table(name: 'sections')]#[Gedmo\TranslationEntity(class: SectionTranslation::class)]#[Serializer\ExclusionPolicy('all')]class Section implements Translatable, \Stringable{/*** @var int*/#[ORM\Column(name: 'id', type: 'integer')]#[ORM\Id]#[ORM\GeneratedValue(strategy: 'AUTO')]#[Serializer\Groups(['MyListings', 'Default', 'Search', 'DefaultV4', 'SearchV4', 'SlugResolver', 'listingDetails', 'leadsBank'])]#[Serializer\Expose]private $id;/*** @var string*/#[ORM\Column(name: 'title', type: 'string', length: 100)]#[Gedmo\Translatable]#[Serializer\Groups(['Default', 'Search', 'DefaultV4', 'SlugResolver', 'listingDetails', 'MyListings', 'MyLeads', 'leadsBank'])]#[Serializer\Expose]private $title;/*** @var string*/#[ORM\Column(name: 'description', type: 'text', length: 512, nullable: true)]#[Gedmo\Translatable]#[Serializer\Groups(['Default', 'DefaultV4'])]#[Serializer\Expose]private $description;/*** @var string*/#[ORM\Column(name: 'meta_title', type: 'string', length: 100)]#[Gedmo\Translatable]#[Serializer\Groups(['Default'])]#[Serializer\Expose]private $metaTitle;/*** @var string*/#[ORM\Column(name: 'meta_description', type: 'text', length: 512, nullable: true)]#[Gedmo\Translatable]#[Serializer\Groups(['Default', 'DefaultV4'])]#[Serializer\Expose]private $metaDescription;/*** @var bool*/#[ORM\Column(name: 'main', type: 'boolean')]#[Serializer\Groups(['Default'])]#[Serializer\Expose]private $main = false;/*** @var bool*/#[ORM\Column(name: 'searchable', type: 'boolean')]#[Serializer\Groups(['Default'])]#[Serializer\Expose]private $searchable = false;#[ORM\Column(length: 128, unique: true)]#[Gedmo\Slug(fields: ['title'], updatable: false)]#[Serializer\Groups(['Default', 'DefaultV4', 'SlugResolver', 'SearchV4', 'listingDetails'])]#[Serializer\Expose]private $slug;#[ORM\OneToMany(targetEntity: SectionTranslation::class, mappedBy: 'object', cascade: ['persist', 'remove'])]private $translations;#[ORM\OneToMany(targetEntity: Listing::class, mappedBy: 'section', fetch: 'EXTRA_LAZY')]protected $listings;#[ORM\OneToMany(targetEntity: \Aqarmap\Bundle\NeighborhoodBundle\Entity\LocationStatistics::class, mappedBy: 'section', fetch: 'EXTRA_LAZY')]protected $locationStatistics;#[ORM\OneToMany(targetEntity: PriceFilter::class, mappedBy: 'section', fetch: 'EXTRA_LAZY')]protected $priceFilter;#[ORM\OneToMany(targetEntity: Rule::class, mappedBy: 'section', fetch: 'EXTRA_LAZY')]protected $rules;#[ORM\OneToMany(targetEntity: UserInterest::class, mappedBy: 'section')]protected $interests;#[ORM\OneToMany(targetEntity: ExchangeRequest::class, mappedBy: 'section', fetch: 'EXTRA_LAZY')]protected $exchangeRequests;#[Gedmo\Locale] // Used locale to override Translation listener`s localeprivate $locale;#[ORM\Column(name: 'synced', type: 'boolean')]private $synced = false;#[ORM\Column(name: 'reference_id', type: 'integer', nullable: true)]private $referenceId;/*** @var string*/#[ORM\Column(name: 'meta_search_description', type: 'text', length: 512, nullable: true)]#[Gedmo\Translatable]private $metaSearchDescription;/*** @var array*/private $v4Translations = [];/*** Constructor.*/public function __construct(){$this->translations = new ArrayCollection();$this->listings = new ArrayCollection();$this->locationStatistics = new ArrayCollection();$this->priceFilter = new ArrayCollection();$this->rules = new ArrayCollection();$this->interests = new ArrayCollection();$this->exchangeRequests = new ArrayCollection();}// ---------------------------------------------------------------------/*** Get id.** @return int*/public function getId(){return $this->id;}// ---------------------------------------------------------------------/*** Set title.** @param string $title** @return Section*/public function setTitle($title){$this->title = $title;return $this;}/*** Get title.** @return string*/public function getTitle(){return $this->title;}// ---------------------------------------------------------------------/*** Set description.** @param string $description** @return Section*/public function setDescription($description){$this->title = $description;return $this;}/*** Get description.** @return string*/public function getDescription(){return $this->description;}// ---------------------------------------------------------------------/*** Set main.** @param bool $main** @return Section*/public function setMain($main){$this->main = $main;return $this;}/*** Get main.** @return bool*/public function getMain(){return $this->main;}// ---------------------------------------------------------------------/*** Set searchable.** @param bool $searchable** @return Section*/public function setSearchable($searchable){$this->searchable = $searchable;return $this;}/*** Get searchable.** @return bool*/public function getSearchable(){return $this->searchable;}/*** @return bool*/#[Serializer\VirtualProperty]#[Serializer\Groups(['DefaultV4'])]#[Serializer\Expose]public function isSearchable(){return (bool) $this->searchable;}/*** @return bool*/#[Serializer\VirtualProperty]#[Serializer\Groups(['DefaultV4'])]#[Serializer\Expose]public function isMain(){return (bool) $this->main;}/*** @return string*/#[Serializer\VirtualProperty]#[Serializer\Groups(['DefaultV4'])]#[Serializer\SerializedName('inheritanceType')]#[Serializer\Expose]public function getInheritanceType(){return str_replace('-', '_', $this->getSlug());}// ---------------------------------------------------------------------/*** Set slug.** @param string $slug** @return Section*/public function setSlug($slug){$this->slug = $slug;return $this;}/*** Get slug.** @return string*/public function getSlug(){return $this->slug;}// ---------------------------------------------------------------------/*** Get translations.** @return ArrayCollection*/public function getTranslations(){return $this->translations;}public function getTranslatableLocale(){return $this->locale;}/*** Add translation.** @return Section*/public function addTranslation(SectionTranslation $translation){if (!$this->translations->contains($translation)) {$this->translations->add($translation);$translation->setObject($this);}return $this;}/*** Remove translation.** @return Section*/public function removeTranslation(SectionTranslation $translation){if ($this->translations->contains($translation)) {$this->translations->removeElement($translation);}return $this;}// ---------------------------------------------------------------------/*** Add listings.** @return Section*/public function addListing(Listing $listings){$this->listings[] = $listings;return $this;}/*** Remove listings.*/public function removeListing(Listing $listings): void{$this->listings->removeElement($listings);}/*** Get listings.** @return \Doctrine\Common\Collections\Collection*/public function getListings(){return $this->listings;}/*** @param array $locations** @return \Doctrine\Common\Collections\Collection*/public function getLocationListings($locations){$criteria = Criteria::create()->where(Criteria::expr()->in('location', $locations))->andWhere(Criteria::expr()->eq('status', ListingStatus::LIVE))->orderBy(['featured' => Criteria::DESC, 'publishedAt' => Criteria::DESC])->setMaxResults(6);return $this->getListings()->matching($criteria);}// ---------------------------------------------------------------------/*** Add priceFilter.** @return Section*/public function addPriceFilter(PriceFilter $priceFilter){$this->priceFilter[] = $priceFilter;return $this;}/*** Remove priceFilter.*/public function removePriceFilter(PriceFilter $priceFilter): void{$this->priceFilter->removeElement($priceFilter);}/*** Get priceFilter.** @return \Doctrine\Common\Collections\Collection*/public function getPriceFilter(){return $this->priceFilter;}// ---------------------------------------------------------------------/*** Add rules.** @return Section*/public function addRule(Rule $rules){$this->rules[] = $rules;return $this;}/*** Remove rules.*/public function removeRule(Rule $rules): void{$this->rules->removeElement($rules);}/*** Get rules.** @return \Doctrine\Common\Collections\Collection*/public function getRules(){return $this->rules;}// ---------------------------------------------------------------------/*** Add locationStatistic.** @return Section*/public function addLocationStatistic(\Aqarmap\Bundle\NeighborhoodBundle\Entity\LocationStatistics $locationStatistic){$this->locationStatistics[] = $locationStatistic;return $this;}/*** Remove locationStatistic.*/public function removeLocationStatistic(\Aqarmap\Bundle\NeighborhoodBundle\Entity\LocationStatistics $locationStatistic): void{$this->locationStatistics->removeElement($locationStatistic);}/*** Get locationStatistics.** @return \Doctrine\Common\Collections\Collection*/public function getLocationStatistics(){return $this->locationStatistics;}/*** Add interest.** @return Section*/public function addInterest(UserInterest $interest){$this->interests[] = $interest;return $this;}/*** Remove interest.*/public function removeInterest(UserInterest $interest): void{$this->interests->removeElement($interest);}/*** Get interests.** @return \Doctrine\Common\Collections\Collection*/public function getInterests(){return $this->interests;}public function setTranslatableLocale($locale): void{$this->locale = $locale;}/*** Add exchangeRequest.** @return Section*/public function addExchangeRequest(ExchangeRequest $exchangeRequest){$this->exchangeRequests[] = $exchangeRequest;return $this;}/*** Remove exchangeRequest.*/public function removeExchangeRequest(ExchangeRequest $exchangeRequest): void{$this->exchangeRequests->removeElement($exchangeRequest);}/*** Get exchangeRequests.** @return \Doctrine\Common\Collections\Collection*/public function getExchangeRequests(){return $this->exchangeRequests;}public function __toString(): string{return $this->title;}/*** @return string*/public function getMetaDescription(){return $this->metaDescription;}/*** @param string $metaDescription*/public function setMetaDescription($metaDescription): void{$this->metaDescription = $metaDescription;}/*** @return string*/public function getMetaTitle(){return $this->metaTitle;}/*** @param string $metaTitle** @return $this*/public function setMetaTitle($metaTitle){$this->metaTitle = $metaTitle;return $this;}/*** @return self*/public function setSynced(bool $synced = false){$this->synced = $synced;return $this;}/*** @return bool|null*/public function getSynced(){return $this->synced;}/*** @return string|null*/public function getMetaSearchDescription(){return $this->metaSearchDescription;}/*** @return Section*/public function setMetaSearchDescription(string $metaSearchDescription){$this->metaSearchDescription = $metaSearchDescription;return $this;}/*** @return int|null*/#[Serializer\VirtualProperty]#[Serializer\Groups(['Default'])]#[Serializer\Expose]public function getReferenceId(){return $this->id;}/*** @return self*/public function setReferenceId(?int $referenceId){$this->referenceId = $referenceId;return $this;}#[Serializer\VirtualProperty]#[Serializer\SerializedName('referenceId')]#[Serializer\Expose]#[Serializer\Groups(['DefaultV4'])]public function getReferencedV4Id(){return $this->getId();}/*** @param array $translations** @return self*/public function setV4Translations($translations = []){$this->v4Translations = $translations;return $this;}/*** Get translations.** @return array*/#[Serializer\VirtualProperty]#[Serializer\Groups(['DefaultV4', 'MyListing'])]#[Serializer\SerializedName('translations')]#[Serializer\Expose]public function getV4Translations(){return $this->v4Translations;}}