vendor/score/cms/src/Entity/Block/BlockJoint.php line 20

Open in your IDE?
  1. <?php
  2. namespace Score\CmsBundle\Entity\Block;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Score\BaseBundle\Entity\BaseEntity;
  5. use Score\CmsBundle\Entity\Block\BlockJointArticle;
  6. use Score\CmsBundle\Entity\Block\BlockJointDocument;
  7. use Score\CmsBundle\Entity\Block\BlockJointEvent;
  8. use Score\CmsBundle\Entity\Block\BlockJointPage;
  9. /**
  10.  * @ORM\Entity()
  11.  * @ORM\InheritanceType("SINGLE_TABLE")
  12.  * @ORM\DiscriminatorColumn(name="joint_entity", type="string")
  13.  * @ORM\DiscriminatorMap({"article"="BlockJointArticle", "document"="BlockJointDocument", "event"="BlockJointEvent", "page"="BlockJointPage" })
  14.  * @ORM\Table(name="cms_block_joint")
  15.  * @ORM\HasLifecycleCallbacks()
  16.  */
  17. class BlockJoint extends BaseEntity {
  18.     /**
  19.      * @ORM\ManyToOne(targetEntity="Block", inversedBy="blockJoints")
  20.      * @ORM\JoinColumn(name="block_id", referencedColumnName="id")
  21.      */
  22.     protected $block;
  23.     /**
  24.      * @ORM\Column(name="entity_id", type="integer", nullable=true)
  25.      */
  26.     protected $entityId;
  27.     /**
  28.      * @ORM\Column(name="sort_order", type="integer", nullable = true)
  29.      */
  30.     protected $sortOrder;
  31.     /**
  32.      * @ORM\Column(name="j_place", type="string", nullable = true)
  33.      */
  34.     protected $place;
  35.     /**
  36.      * @ORM\Column(name="j_params", type="string", length=2000, nullable=true)
  37.      */
  38.     protected $params;
  39.     // custom
  40.     public function getEntityId() {
  41.         return $this->entityId;
  42.     }
  43.     // custom
  44.     public function getBlockId() {
  45.         return $this->getBlock()->getId();
  46.     }
  47.     public function getSortOrder() {
  48.         return $this->sortOrder;
  49.     }
  50.     public function getStatus() {
  51.         return $this->status;
  52.     }
  53.     public function getLang() {
  54.         return $this->lang;
  55.     }
  56.     public function getBlock():Block {
  57.         return $this->block;
  58.     }
  59.     public function getPlace() {
  60.         return $this->place;
  61.     }
  62.     public function setSortOrder($sortOrder) {
  63.         $this->sortOrder = $sortOrder;
  64.         return $this;
  65.     }
  66.     public function setStatus($status) {
  67.         $this->status = $status;
  68.         return $this;
  69.     }
  70.     public function setLang($lang) {
  71.         $this->lang = $lang;
  72.         return $this;
  73.     }
  74.     public function setBlock(Block $block) {
  75.         $this->block = $block;
  76.         return $this;
  77.     }
  78.     public function setPlace($place) {
  79.         $this->place = $place;
  80.         return $this;
  81.     }
  82.     public function getParams(): ?string {
  83.         return $this->params;
  84.     }
  85.     public function setParams(?string $params): self {
  86.         $this->params = $params;
  87.         return $this;
  88.     }
  89.     public function getParamsArr(): ?array {
  90.         return json_decode($this->params, true);
  91.     }
  92.     public function setParamsArr(?array $params): self {
  93.         $this->params = json_encode($params);
  94.         return $this;
  95.     }
  96.     public function getParamByKey($key, $defaultValue = null) {
  97.         $arr = $this->getParamsArr();
  98.         if (is_array($arr) && array_key_exists($key, $arr)) {
  99.             return $arr[$key];
  100.         }
  101.         return $defaultValue;
  102.     }
  103.     public function setParamByKey($key, $value) {
  104.         $arr = $this->getParamsArr();
  105.         if (is_array($arr)) {
  106.             $arr[$key] = $value;
  107.         } else {
  108.             $arr = [$key => $value];
  109.         }
  110.         return $this->setParamsArr($arr);
  111.     }
  112. }