src/Products/NotificationsBundle/Entity/Notifications/Invocation.php line 22

Open in your IDE?
  1. <?php
  2. namespace Products\NotificationsBundle\Entity\Notifications;
  3. use App\Model\Query\ConditionQuery\ConditionQuery;
  4. use DateTime;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\Common\Collections\Criteria;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Products\NotificationsBundle\Entity\AbstractNotification;
  10. use Products\NotificationsBundle\Entity\Automation;
  11. use Products\NotificationsBundle\Entity\Lists\ConditionList;
  12. use Products\NotificationsBundle\Entity\Notifications\Channels\ChannelsInterface;
  13. /**
  14.  *
  15.  * @ORM\Entity(
  16.  *     repositoryClass = "Products\NotificationsBundle\Doctrine\Repository\Notifications\InvocationRepository",
  17.  * )
  18.  */
  19. class Invocation extends AbstractNotification
  20. {
  21.     public const DISCR 'invocation';
  22.     /**
  23.      * @var Automation|null
  24.      *
  25.      * @ORM\ManyToOne(
  26.      *     targetEntity = Automation::class,
  27.      *     inversedBy="invocations"
  28.      * )
  29.      * @ORM\JoinColumn(
  30.      *     name = "automation",
  31.      *     referencedColumnName = "id",
  32.      *     nullable = true,
  33.      *     onDelete = "SET NULL",
  34.      * )
  35.      */
  36.     private ?Automation $automation;
  37.     /**
  38.      * @var ConditionQuery|null
  39.      *
  40.      * @ORM\Column(
  41.      *     type = "condition_query",
  42.      *     nullable = true,
  43.      * )
  44.      */
  45.     private ?ConditionQuery $conditionQuery;
  46.     /**
  47.      * @var DateTime|null
  48.      *
  49.      * @ORM\Column(
  50.      *     type = "datetime",
  51.      *     nullable = false,
  52.      * )
  53.      */
  54.     private ?DateTime $invocationTimestamp;
  55.     /**
  56.      * @return Automation|null
  57.      */
  58.     public function getAutomation(): ?Automation
  59.     {
  60.         return $this->automation;
  61.     }
  62.     /**
  63.      * @param Automation|null $automation
  64.      * @return self
  65.      */
  66.     public function setAutomation(?Automation $automation): self
  67.     {
  68.         $this->automation $automation;
  69.         return $this;
  70.     }
  71.     /**
  72.      * @return ConditionQuery|null
  73.      */
  74.     public function getConditionQuery(): ?ConditionQuery
  75.     {
  76.         return $this->conditionQuery;
  77.     }
  78.     /**
  79.      * @param ConditionQuery|null $conditionQuery
  80.      * @return self
  81.      */
  82.     public function setConditionQuery(?ConditionQuery $conditionQuery): self
  83.     {
  84.         $this->conditionQuery $conditionQuery;
  85.         return $this;
  86.     }
  87.     /**
  88.      * @return DateTime|null
  89.      */
  90.     public function getInvocationTimestamp(): ?DateTime
  91.     {
  92.         return $this->invocationTimestamp;
  93.     }
  94.     /**
  95.      * @param DateTime|null $invocationTimestamp
  96.      * @return self
  97.      */
  98.     public function setInvocationTimestamp(?DateTime $invocationTimestamp): self
  99.     {
  100.         $this->invocationTimestamp $invocationTimestamp;
  101.         return $this;
  102.     }
  103.     /**
  104.      * {@inheritDoc}
  105.      */
  106.     public function getLists(?Criteria $criteria null): Collection
  107.     {
  108.         $conditionQuery $this->getConditionQuery();
  109.         if ( ! $conditionQuery instanceof ConditionQuery) {
  110.             return new ArrayCollection();
  111.         }
  112.         return new ArrayCollection([
  113.             (new ConditionList($conditionQuery))
  114.                 ->setTenant($this->getTenant()),
  115.         ]);
  116.     }
  117.     /**
  118.      * {@inheritDoc}
  119.      */
  120.     public function setLists(iterable $lists): self
  121.     {
  122.         return $this;
  123.     }
  124.     /**
  125.      * {@inheritDoc}
  126.      */
  127.     public function setChannels(int $channels): AbstractNotification
  128.     {
  129.         $skips ChannelsInterface::CHANNELS__WEBSITE
  130.             ChannelsInterface::CHANNELS__TWITTER
  131.             ChannelsInterface::CHANNELS__FACEBOOK;
  132.         return parent::setChannels($channels & ~$skips);
  133.     }
  134.     /**
  135.      * {@inheritDoc}
  136.      */
  137.     public function isPublic(): bool
  138.     {
  139.         return false;
  140.     }
  141. }