vendor/score/cms/src/Entity/Block/Block.php line 250

Open in your IDE?
  1. <?php
  2. namespace Score\CmsBundle\Entity\Block;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Score\BaseBundle\Entity\BaseEntity;
  7. use Score\CmsBundle\Repository\BlockRepository;
  8. /**
  9.  * Block
  10.  * @ORM\Entity(repositoryClass=BlockRepository::class)
  11.  * @ORM\Table(name="cms_block")
  12.  * @ORM\HasLifecycleCallbacks()
  13.  */
  14. class Block extends BaseEntity {
  15.     /**
  16.      * @var string
  17.      *
  18.      * @ORM\Column(name="name", type="string", length=100, nullable=false)
  19.      */
  20.     protected $name;
  21.     /**
  22.      * @var string
  23.      *
  24.      * @ORM\Column(name="perex", type="text", nullable=true)
  25.      */
  26.     protected $perex;
  27.     /**
  28.      * @var string
  29.      *
  30.      * @ORM\Column(name="content", type="text", nullable=true)
  31.      */
  32.     protected $content;
  33.     /**
  34.      * @var string
  35.      *
  36.      * @ORM\Column(name="lang", type="string", length=50, nullable=true)
  37.      */
  38.     protected $lang;
  39.     /**
  40.      * @var string
  41.      *
  42.      * @ORM\Column(name="module", type="string", length=200, nullable=true)
  43.      */
  44.     protected $module;
  45.     /**
  46.      * @var string
  47.      *
  48.      * @ORM\Column(name="action", type="string", length=200, nullable=true)
  49.      */
  50.     protected $action;
  51.     /**
  52.      * @var string
  53.      *
  54.      * @ORM\Column(name="params", type="text", nullable=true)
  55.      */
  56.     protected $params;
  57.     /**
  58.      * @var string
  59.      *
  60.      * @ORM\Column(name="type", type="string", length=200, nullable=true)
  61.      */
  62.     protected $type;
  63.     /**
  64.      * @var integer
  65.      *
  66.      * @ORM\Column(name="sort_order", type="integer", nullable=true)
  67.      */
  68.     protected $sortOrder;
  69.     /**
  70.      * @ORM\OneToMany(targetEntity=BlockJoint::class, mappedBy="block", cascade={"persist", "remove"}, orphanRemoval=true)
  71.      */
  72.     protected $blockJoints;
  73.     /**
  74.      * @var string
  75.      *
  76.      * @ORM\Column(name="description", type="text", nullable=true)
  77.      */
  78.     protected $description;
  79.     /**
  80.      * Set name
  81.      *
  82.      * @param string $name
  83.      * @return Block
  84.      */
  85.     public function setName($name) {
  86.         $this->name = $name;
  87.         return $this;
  88.     }
  89.     /**
  90.      * Get name
  91.      *
  92.      * @return string
  93.      */
  94.     public function getName() {
  95.         return $this->name;
  96.     }
  97.     /**
  98.      * Set perex
  99.      *
  100.      * @param string $perex
  101.      * @return Block
  102.      */
  103.     public function setPerex($perex) {
  104.         $this->perex = $perex;
  105.         return $this;
  106.     }
  107.     /**
  108.      * Get perex
  109.      *
  110.      * @return string
  111.      */
  112.     public function getPerex() {
  113.         return $this->perex;
  114.     }
  115.     /**
  116.      * Set content
  117.      *
  118.      * @param string $content
  119.      * @return Block
  120.      */
  121.     public function setContent($content) {
  122.         $this->content = $content;
  123.         return $this;
  124.     }
  125.     /**
  126.      * Get content
  127.      *
  128.      * @return string
  129.      */
  130.     public function getContent() {
  131.         return $this->content;
  132.     }
  133.     /**
  134.      * Set lang
  135.      *
  136.      * @param string $lang
  137.      * @return Block
  138.      */
  139.     public function setLang($lang) {
  140.         $this->lang = $lang;
  141.         return $this;
  142.     }
  143.     /**
  144.      * Get lang
  145.      *
  146.      * @return string
  147.      */
  148.     public function getLang() {
  149.         return $this->lang;
  150.     }
  151.     /**
  152.      * Set module
  153.      *
  154.      * @param string $module
  155.      * @return Block
  156.      */
  157.     public function setModule($module) {
  158.         $this->module = $module;
  159.         return $this;
  160.     }
  161.     /**
  162.      * Get module
  163.      *
  164.      * @return string
  165.      */
  166.     public function getModule() {
  167.         return $this->module;
  168.     }
  169.     /**
  170.      * Set action
  171.      *
  172.      * @param string $action
  173.      * @return Block
  174.      */
  175.     public function setAction($action) {
  176.         $this->action = $action;
  177.         return $this;
  178.     }
  179.     /**
  180.      * Get action
  181.      *
  182.      * @return string
  183.      */
  184.     public function getAction() {
  185.         return $this->action;
  186.     }
  187.     /**
  188.      * Set params
  189.      *
  190.      * @param string $params
  191.      * @return Block
  192.      */
  193.     public function setParams($params) {
  194.         $this->params = $params;
  195.         return $this;
  196.     }
  197.     /**
  198.      * Get params
  199.      *
  200.      * @return string
  201.      */
  202.     public function getParams() {
  203.         return $this->params;
  204.     }
  205.     public function setParamsArr($params) {
  206.         $this->params = json_encode($params);
  207.         return $this;
  208.     }
  209.     public function getParamsArr() {
  210.         return json_decode($this->params, true);
  211.     }
  212.     /**
  213.      * Set type
  214.      *
  215.      * @param string $type
  216.      * @return Block
  217.      */
  218.     public function setType($type) {
  219.         $this->type = $type;
  220.         return $this;
  221.     }
  222.     /**
  223.      * Get type
  224.      *
  225.      * @return string
  226.      */
  227.     public function getType() {
  228.         return $this->type;
  229.     }
  230.     /**
  231.      * Set sortOrder
  232.      *
  233.      * @param integer $sortOrder
  234.      * @return Block
  235.      */
  236.     public function setSortOrder($sortOrder) {
  237.         $this->sortOrder = $sortOrder;
  238.         return $this;
  239.     }
  240.     /**
  241.      * Get sortOrder
  242.      *
  243.      * @return integer
  244.      */
  245.     public function getSortOrder() {
  246.         return $this->sortOrder;
  247.     }
  248.     /**
  249.      * Constructor
  250.      */
  251.     public function __construct() {
  252.         $this->blockJoints = new ArrayCollection();
  253.     }
  254.     public function getMenuId() {
  255.         $params = $this->getParams();
  256.         $settings = json_decode($params, true);
  257.         return $settings['menuId'];
  258.     }
  259.     /**
  260.      * Get the value of description
  261.      *
  262.      * @return  string
  263.      */
  264.     public function getDescription() {
  265.         return $this->description;
  266.     }
  267.     /**
  268.      * Set the value of description
  269.      *
  270.      * @param string $description
  271.      *
  272.      * @return  self
  273.      */
  274.     public function setDescription(string $description) {
  275.         $this->description = $description;
  276.         return $this;
  277.     }
  278.     /**
  279.      * @return Collection<int, BlockJoint>
  280.      */
  281.     public function getBlockJoints(): Collection {
  282.         return $this->blockJoints;
  283.     }
  284.     public function addBlockJoint(BlockJoint $blockJoint): self {
  285.         if (!$this->blockJoints->contains($blockJoint)) {
  286.             $this->blockJoints[] = $blockJoint;
  287.             $blockJoint->setBlock($this);
  288.         }
  289.         return $this;
  290.     }
  291.     public function removeBlockJoint(BlockJoint $blockJoint): self {
  292.         $this->blockJoints->removeElement($blockJoint);
  293.         return $this;
  294.     }
  295. }