vendor/netgen/layouts-core/lib/API/Values/LayoutResolver/Rule.php line 15

  1. <?php
  2. declare(strict_types=1);
  3. namespace Netgen\Layouts\API\Values\LayoutResolver;
  4. use Doctrine\Common\Collections\Collection;
  5. use Netgen\Layouts\API\Values\Layout\Layout;
  6. use Netgen\Layouts\API\Values\LazyPropertyTrait;
  7. use Netgen\Layouts\API\Values\Value;
  8. use Netgen\Layouts\API\Values\ValueStatusTrait;
  9. use Netgen\Layouts\Utils\HydratorTrait;
  10. use Ramsey\Uuid\UuidInterface;
  11. final class Rule implements Value
  12. {
  13.     use HydratorTrait;
  14.     use LazyPropertyTrait;
  15.     use ValueStatusTrait;
  16.     private UuidInterface $id;
  17.     private UuidInterface $ruleGroupId;
  18.     /**
  19.      * @var \Netgen\Layouts\API\Values\Layout\Layout|\Closure|null
  20.      */
  21.     private $layout;
  22.     private bool $enabled;
  23.     private int $priority;
  24.     private string $description;
  25.     /**
  26.      * @var \Doctrine\Common\Collections\Collection<int, \Netgen\Layouts\API\Values\LayoutResolver\Target>
  27.      */
  28.     private Collection $targets;
  29.     /**
  30.      * @var \Doctrine\Common\Collections\Collection<int, \Netgen\Layouts\API\Values\LayoutResolver\Condition>
  31.      */
  32.     private Collection $conditions;
  33.     public function getId(): UuidInterface
  34.     {
  35.         return $this->id;
  36.     }
  37.     /**
  38.      * Returns the UUID of the rule group where this rule belongs.
  39.      */
  40.     public function getRuleGroupId(): UuidInterface
  41.     {
  42.         return $this->ruleGroupId;
  43.     }
  44.     /**
  45.      * Returns the layout mapped to this rule.
  46.      */
  47.     public function getLayout(): ?Layout
  48.     {
  49.         return $this->getLazyProperty($this->layout);
  50.     }
  51.     /**
  52.      * Returns if the rule is enabled.
  53.      */
  54.     public function isEnabled(): bool
  55.     {
  56.         return $this->enabled;
  57.     }
  58.     /**
  59.      * Returns the rule priority.
  60.      */
  61.     public function getPriority(): int
  62.     {
  63.         return $this->priority;
  64.     }
  65.     /**
  66.      * Returns the rule comment.
  67.      *
  68.      * @deprecated use self::getDescription
  69.      */
  70.     public function getComment(): string
  71.     {
  72.         return $this->description;
  73.     }
  74.     /**
  75.      * Returns the rule description.
  76.      */
  77.     public function getDescription(): string
  78.     {
  79.         return $this->description;
  80.     }
  81.     /**
  82.      * Returns all the targets in the rule.
  83.      */
  84.     public function getTargets(): TargetList
  85.     {
  86.         return new TargetList($this->targets->toArray());
  87.     }
  88.     /**
  89.      * Returns all conditions in the rule.
  90.      */
  91.     public function getConditions(): ConditionList
  92.     {
  93.         return new ConditionList($this->conditions->toArray());
  94.     }
  95. }