您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

61 行
1.6KB

  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\CaracoleBundle\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. }