You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 3 година
пре 3 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace Lc\SovBundle\Model\Site;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Lc\SovBundle\Model\Setting\EntitySettingTrait;
  7. use Lc\SovBundle\Model\Setting\SiteSettingInterface;
  8. use Lc\SovBundle\Doctrine\EntityInterface;
  9. use Lc\SovBundle\Doctrine\Extension\DevAliasInterface;
  10. use Lc\SovBundle\Doctrine\Extension\DevAliasTrait;
  11. abstract class SiteModel implements SiteInterface, EntityInterface, DevAliasInterface
  12. {
  13. use EntitySettingTrait;
  14. use DevAliasTrait;
  15. /**
  16. * @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Setting\SiteSettingInterface", mappedBy="site", orphanRemoval=true, cascade={"persist"}, fetch="EAGER")
  17. */
  18. protected $settings;
  19. public function __construct()
  20. {
  21. $this->settings = new ArrayCollection();
  22. }
  23. /**
  24. * @return Collection|SiteSettingInterface[]
  25. */
  26. public function getSettings(): Collection
  27. {
  28. return $this->settings;
  29. }
  30. public function addSetting(SiteSettingInterface $setting): self
  31. {
  32. if (!$this->settings->contains($setting)) {
  33. $this->settings[] = $setting;
  34. $setting->setSite($this);
  35. }
  36. return $this;
  37. }
  38. public function removeSetting(SiteSettingInterface $setting): self
  39. {
  40. if ($this->settings->contains($setting)) {
  41. $this->settings->removeElement($setting);
  42. // set the owning side to null (unless already changed)
  43. if ($setting->getSite() === $this) {
  44. $setting->setSite(null);
  45. }
  46. }
  47. return $this;
  48. }
  49. }