No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

59 líneas
1.5KB

  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\SiteSettingInterface;
  7. use Lc\SovBundle\Doctrine\EntityInterface;
  8. use Lc\SovBundle\Doctrine\Extension\DevAliasInterface;
  9. use Lc\SovBundle\Doctrine\Extension\DevAliasTrait;
  10. abstract class SiteModel implements SiteInterface, EntityInterface, DevAliasInterface
  11. {
  12. use DevAliasTrait;
  13. /**
  14. * @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Setting\SiteSettingInterface", mappedBy="site", orphanRemoval=true, cascade={"persist"}, fetch="EAGER")
  15. */
  16. protected $settings;
  17. public function __construct()
  18. {
  19. $this->settings = new ArrayCollection();
  20. }
  21. /**
  22. * @return Collection|SiteSettingInterface[]
  23. */
  24. public function getSettings(): Collection
  25. {
  26. return $this->settings;
  27. }
  28. public function addSetting(SiteSettingInterface $setting): self
  29. {
  30. if (!$this->settings->contains($setting)) {
  31. $this->settings[] = $setting;
  32. $setting->setSite($this);
  33. }
  34. return $this;
  35. }
  36. public function removeSetting(SiteSettingInterface $setting): self
  37. {
  38. if ($this->settings->contains($setting)) {
  39. $this->settings->removeElement($setting);
  40. // set the owning side to null (unless already changed)
  41. if ($setting->getSite() === $this) {
  42. $setting->setSite(null);
  43. }
  44. }
  45. return $this;
  46. }
  47. }