|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
-
- namespace Lc\SovBundle\Model\Site;
-
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- use Lc\CaracoleBundle\Model\Setting\EntitySettingTrait;
- use Lc\SovBundle\Model\Setting\SiteSettingInterface;
- use Lc\SovBundle\Doctrine\EntityInterface;
- use Lc\SovBundle\Doctrine\Extension\DevAliasInterface;
- use Lc\SovBundle\Doctrine\Extension\DevAliasTrait;
-
- abstract class SiteModel implements SiteInterface, EntityInterface, DevAliasInterface
- {
- use EntitySettingTrait;
- use DevAliasTrait;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Setting\SiteSettingInterface", mappedBy="site", orphanRemoval=true, cascade={"persist"}, fetch="EAGER")
- */
- protected $settings;
-
- public function __construct()
- {
- $this->settings = new ArrayCollection();
- }
-
- /**
- * @return Collection|SiteSettingInterface[]
- */
- public function getSettings(): Collection
- {
- return $this->settings;
- }
-
- public function addSetting(SiteSettingInterface $setting): self
- {
- if (!$this->settings->contains($setting)) {
- $this->settings[] = $setting;
- $setting->setSite($this);
- }
-
- return $this;
- }
-
- public function removeSetting(SiteSettingInterface $setting): self
- {
- if ($this->settings->contains($setting)) {
- $this->settings->removeElement($setting);
- // set the owning side to null (unless already changed)
- if ($setting->getSite() === $this) {
- $setting->setSite(null);
- }
- }
-
- return $this;
- }
-
- }
|