vendor/setono/sylius-terms-plugin/src/Model/Terms.php line 14

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Setono\SyliusTermsPlugin\Model;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Sylius\Component\Channel\Model\ChannelInterface;
  7. use Sylius\Component\Resource\Model\TimestampableTrait;
  8. use Sylius\Component\Resource\Model\TranslatableTrait;
  9. use Sylius\Component\Resource\Model\TranslationInterface;
  10. class Terms implements TermsInterface
  11. {
  12.     use TimestampableTrait;
  13.     use TranslatableTrait {
  14.         __construct as private initializeTranslationsCollection;
  15.         getTranslation as private doGetTranslation;
  16.     }
  17.     public function __construct()
  18.     {
  19.         $this->channels = new ArrayCollection();
  20.         $this->initializeTranslationsCollection();
  21.     }
  22.     /** @var int */
  23.     protected $id;
  24.     /** @var Collection|ChannelInterface[] */
  25.     protected $channels;
  26.     /** @var string|null */
  27.     protected $code;
  28.     public function getId(): ?int
  29.     {
  30.         return $this->id;
  31.     }
  32.     public function getChannels(): Collection
  33.     {
  34.         return $this->channels;
  35.     }
  36.     public function hasChannel(ChannelInterface $channel): bool
  37.     {
  38.         return $this->channels->contains($channel);
  39.     }
  40.     public function addChannel(ChannelInterface $channel): void
  41.     {
  42.         if (!$this->hasChannel($channel)) {
  43.             $this->channels->add($channel);
  44.         }
  45.     }
  46.     public function removeChannel(ChannelInterface $channel): void
  47.     {
  48.         if ($this->hasChannel($channel)) {
  49.             $this->channels->removeElement($channel);
  50.         }
  51.     }
  52.     public function getCode(): ?string
  53.     {
  54.         return $this->code;
  55.     }
  56.     public function setCode(?string $code): void
  57.     {
  58.         $this->code $code;
  59.     }
  60.     public function getName(): ?string
  61.     {
  62.         return $this->getTranslation()->getName();
  63.     }
  64.     public function setName(?string $name): void
  65.     {
  66.         $this->getTranslation()->setName($name);
  67.     }
  68.     public function getSlug(): ?string
  69.     {
  70.         return $this->getTranslation()->getSlug();
  71.     }
  72.     public function setSlug(?string $slug): void
  73.     {
  74.         $this->getTranslation()->setSlug($slug);
  75.     }
  76.     public function getExplanation(): ?string
  77.     {
  78.         return $this->getTranslation()->getExplanation();
  79.     }
  80.     public function setExplanation(?string $explanation): void
  81.     {
  82.         $this->getTranslation()->setExplanation($explanation);
  83.     }
  84.     public function getContent(): ?string
  85.     {
  86.         return $this->getTranslation()->getContent();
  87.     }
  88.     public function setContent(?string $content): void
  89.     {
  90.         $this->getTranslation()->setContent($content);
  91.     }
  92.     /**
  93.      * @return TermsTranslationInterface
  94.      */
  95.     public function getTranslation(?string $locale null): TranslationInterface
  96.     {
  97.         /** @var TermsTranslationInterface $translation */
  98.         $translation $this->doGetTranslation($locale);
  99.         return $translation;
  100.     }
  101.     protected function createTranslation(): TermsTranslationInterface
  102.     {
  103.         return new TermsTranslation();
  104.     }
  105. }