src/Submarine/PagesBundle/Entity/Type/PageType.php line 22

Open in your IDE?
  1. <?php
  2. /**
  3.  * (c) itmedia.by <info@itmedia.by>
  4.  */
  5. namespace Submarine\PagesBundle\Entity\Type;
  6. use Submarine\CoreBundle\AccessControl\Role;
  7. use Submarine\CoreBundle\Entity\SubmarineEntityInterface;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. /**
  12.  * Тип страницы
  13.  * @package Submarine\PagesBundle
  14.  *
  15.  * @ORM\Entity()
  16.  * @ORM\Table(name="submarine_pages_types")
  17.  */
  18. class PageType implements SubmarineEntityInterface
  19. {
  20.     /**
  21.      * Сортировака по умолчанию
  22.      */
  23.     const SORT_POSITION 0;
  24.     /**
  25.      * Сортировка по дпте
  26.      */
  27.     const SORT_PUBLISHED 1;
  28.     /**
  29.      * ID
  30.      * @var string
  31.      *
  32.      * @ORM\Column(name="id", type="string", nullable=false, unique=true)
  33.      * @ORM\Id()
  34.      *
  35.      * @Assert\NotBlank()
  36.      * @Assert\Regex(
  37.      *      pattern="/^[a-zA-Z0-9_]+$/i"
  38.      * )
  39.      */
  40.     private $id;
  41.     /**
  42.      * Дополнительные поля
  43.      * @var PageTypeField[]
  44.      *
  45.      * @ORM\OneToMany(
  46.      *      targetEntity="Submarine\PagesBundle\Entity\Type\PageTypeField",
  47.      *      mappedBy="type",
  48.      *      cascade={"REMOVE"},
  49.      *     indexBy="id"
  50.      * )
  51.      * @ORM\OrderBy({"position" = "ASC", "title" = "ASC"})
  52.      */
  53.     private $fields;
  54.     /**
  55.      * @var string
  56.      * @ORM\Column(type="string", length=128, nullable=false)
  57.      *
  58.      * @Assert\NotBlank()
  59.      */
  60.     private $title;
  61.     /**
  62.      * @var string
  63.      * @ORM\Column(name="description", type="string", length=1024, nullable=true)
  64.      */
  65.     private $description;
  66.     /**
  67.      * @var integer
  68.      * @ORM\Column(name="position", type="integer", nullable=false)
  69.      *
  70.      * @Assert\NotNull()
  71.      */
  72.     private $position 10;
  73.     /**
  74.      * @var string
  75.      * @ORM\Column(name="role_create", type="string", length=32, nullable=false)
  76.      */
  77.     private $roleCreate Role::ROLE_ADMIN;
  78.     /**
  79.      * @var string
  80.      * @ORM\Column(name="role_edit", type="string", length=32, nullable=false)
  81.      */
  82.     private $roleEdit Role::ROLE_ADMIN;
  83.     /**
  84.      * @var string
  85.      * @ORM\Column(name="role_remove", type="string", length=32, nullable=false)
  86.      */
  87.     private $roleRemove Role::ROLE_ADMIN;
  88.     /**
  89.      * @var boolean
  90.      * @ORM\Column(name="is_directory", type="boolean", nullable=true)
  91.      */
  92.     private $directory false;
  93.     /**
  94.      * @var boolean
  95.      * @ORM\Column(name="allow_image", type="boolean", nullable=true)
  96.      */
  97.     private $allowImage true;
  98.     /**
  99.      * @var boolean
  100.      * @ORM\Column(name="allow_files", type="boolean", nullable=true)
  101.      */
  102.     private $allowFiles false;
  103.     /**
  104.      * @var boolean
  105.      * @ORM\Column(name="allow_images", type="boolean", nullable=true)
  106.      */
  107.     private $allowImages false;
  108.     /**
  109.      * @var boolean
  110.      * @ORM\Column(name="allow_comments", type="boolean", nullable=true)
  111.      */
  112.     private $allowComments false;
  113.     /**
  114.      * @var bool
  115.      * @ORM\Column(name="allow_properties", type="boolean", nullable=true)
  116.      */
  117.     private $allowProperties false;
  118.     /**
  119.      * @var bool
  120.      * @ORM\Column(name="allow_linked_pages", type="boolean", nullable=true)
  121.      */
  122.     private $allowLinkedPages false;
  123.     /**
  124.      * @var bool
  125.      * @ORM\Column(name="disable_changing_price", type="boolean", nullable=true)
  126.      */
  127.     private $disableChangingPrice false;
  128.     /**
  129.      * Тип связанных страниц
  130.      * @var PageType|null
  131.      * @ORM\ManyToOne(targetEntity="Submarine\PagesBundle\Entity\Type\PageType")
  132.      * @ORM\JoinColumn(name="linked_pages_type_id", referencedColumnName="id")
  133.      */
  134.     private $linkedPagesType;
  135.     /**
  136.      * @ORM\Column(name="is_product", type="boolean", nullable=true)
  137.      * @var boolean
  138.      */
  139.     private $product false;
  140.     /**
  141.      * @var \DateTime
  142.      * @ORM\Column(name="created_at", type="datetime", nullable=false)
  143.      */
  144.     private $createdAt;
  145.     /**
  146.      * Сортировка страниц внутри папки
  147.      *
  148.      * @var int
  149.      * @ORM\Column(name="sorting_type", name="sorting", type="integer", nullable=true)
  150.      */
  151.     private $sortingType self::SORT_POSITION;
  152.     /**
  153.      * Класс картинки для отображения в списке документов
  154.      *
  155.      * @var string
  156.      * @ORM\Column(name="html_class", type="string", nullable=true)
  157.      *
  158.      * @Assert\NotBlank()
  159.      */
  160.     private $htmlClass 'glyphicon-file';
  161.     /**
  162.      * Маска URL
  163.      * @var string
  164.      *
  165.      * @ORM\Column(name="url_mask", type="string", nullable=false)
  166.      * @Assert\NotBlank()
  167.      */
  168.     private $urlMask '/{tag}';
  169.     /**
  170.      * Имя сущности
  171.      * @return string
  172.      */
  173.     public static function entityName()
  174.     {
  175.         return __CLASS__;
  176.     }
  177.     public function __construct()
  178.     {
  179.         $this->createdAt = new \DateTime();
  180.         $this->fields = new ArrayCollection();
  181.     }
  182.     /**
  183.      * @return mixed
  184.      */
  185.     public function getId()
  186.     {
  187.         return $this->id;
  188.     }
  189.     /**
  190.      * @param mixed $id
  191.      */
  192.     public function setId($id)
  193.     {
  194.         $this->id $id;
  195.     }
  196.     /**
  197.      * @return string
  198.      */
  199.     public function getTitle()
  200.     {
  201.         return $this->title;
  202.     }
  203.     /**
  204.      * @param string $title
  205.      */
  206.     public function setTitle($title)
  207.     {
  208.         $this->title $title;
  209.     }
  210.     /**
  211.      * @return string
  212.      */
  213.     public function getDescription()
  214.     {
  215.         return $this->description;
  216.     }
  217.     /**
  218.      * @param string $description
  219.      */
  220.     public function setDescription($description)
  221.     {
  222.         $this->description $description;
  223.     }
  224.     /**
  225.      * @return int
  226.      */
  227.     public function getPosition()
  228.     {
  229.         return $this->position;
  230.     }
  231.     /**
  232.      * @param int $position
  233.      */
  234.     public function setPosition($position)
  235.     {
  236.         $this->position $position;
  237.     }
  238.     /**
  239.      * @return string
  240.      */
  241.     public function getRoleCreate()
  242.     {
  243.         return $this->roleCreate;
  244.     }
  245.     /**
  246.      * @param string $roleCreatePage
  247.      */
  248.     public function setRoleCreate($roleCreatePage)
  249.     {
  250.         $this->roleCreate $roleCreatePage;
  251.     }
  252.     /**
  253.      * @return string
  254.      */
  255.     public function getRoleEdit()
  256.     {
  257.         return $this->roleEdit;
  258.     }
  259.     /**
  260.      * @param string $roleChangePage
  261.      */
  262.     public function setRoleEdit($roleChangePage)
  263.     {
  264.         $this->roleEdit $roleChangePage;
  265.     }
  266.     /**
  267.      * @return string
  268.      */
  269.     public function getRoleRemove()
  270.     {
  271.         return $this->roleRemove;
  272.     }
  273.     /**
  274.      * @param string $roleDeletePage
  275.      */
  276.     public function setRoleRemove($roleDeletePage)
  277.     {
  278.         $this->roleRemove $roleDeletePage;
  279.     }
  280.     /**
  281.      * @param boolean $directory
  282.      */
  283.     public function setDirectory($directory)
  284.     {
  285.         $this->directory $directory;
  286.     }
  287.     /**
  288.      * @return boolean
  289.      */
  290.     public function isDirectory()
  291.     {
  292.         return $this->directory;
  293.     }
  294.     /**
  295.      * @return int
  296.      */
  297.     public function getSortingType()
  298.     {
  299.         return $this->sortingType;
  300.     }
  301.     /**
  302.      * @param int $sorting
  303.      */
  304.     public function setSortingType($sorting)
  305.     {
  306.         $this->sortingType $sorting;
  307.     }
  308.     /**
  309.      * @return string
  310.      */
  311.     public function getHtmlClass()
  312.     {
  313.         return $this->htmlClass;
  314.     }
  315.     /**
  316.      * @param string $htmlClass
  317.      */
  318.     public function setHtmlClass($htmlClass)
  319.     {
  320.         $this->htmlClass $htmlClass;
  321.     }
  322.     /**
  323.      * @return PageTypeField[]
  324.      */
  325.     public function getFields()
  326.     {
  327.         return $this->fields;
  328.     }
  329.     /**
  330.      * Существует ли поле с именем
  331.      *
  332.      * @param $id
  333.      *
  334.      * @return bool
  335.      */
  336.     public function hasField($id)
  337.     {
  338.         return $this->fields->containsKey($id);
  339.     }
  340.     /**
  341.      * Поле
  342.      *
  343.      * @param $id
  344.      *
  345.      * @return PageTypeField|null
  346.      */
  347.     public function getField($id)
  348.     {
  349.         return $this->fields->get($id);
  350.     }
  351.     /**
  352.      * @return \DateTime
  353.      */
  354.     public function getCreatedAt()
  355.     {
  356.         return $this->createdAt;
  357.     }
  358.     /**
  359.      * @return boolean
  360.      */
  361.     public function isAllowImages()
  362.     {
  363.         return $this->allowImages;
  364.     }
  365.     /**
  366.      * @param boolean $allowedImages
  367.      */
  368.     public function setAllowImages($allowedImages)
  369.     {
  370.         $this->allowImages $allowedImages;
  371.     }
  372.     /**
  373.      * @return boolean
  374.      */
  375.     public function isAllowImage()
  376.     {
  377.         return $this->allowImage;
  378.     }
  379.     /**
  380.      * @param boolean $allowedImage
  381.      */
  382.     public function setAllowImage($allowedImage)
  383.     {
  384.         $this->allowImage $allowedImage;
  385.     }
  386.     /**
  387.      * @return boolean
  388.      */
  389.     public function isAllowFiles()
  390.     {
  391.         return $this->allowFiles;
  392.     }
  393.     /**
  394.      * @param boolean $allowedFiles
  395.      */
  396.     public function setAllowFiles($allowedFiles)
  397.     {
  398.         $this->allowFiles $allowedFiles;
  399.     }
  400.     /**
  401.      * @return boolean
  402.      */
  403.     public function isAllowComments()
  404.     {
  405.         return $this->allowComments;
  406.     }
  407.     /**
  408.      * @param boolean $allowedComments
  409.      */
  410.     public function setAllowComments($allowedComments)
  411.     {
  412.         $this->allowComments $allowedComments;
  413.     }
  414.     /**
  415.      * @return boolean
  416.      */
  417.     public function isAllowProperties()
  418.     {
  419.         return $this->allowProperties;
  420.     }
  421.     /**
  422.      * @param boolean $allowProperties
  423.      */
  424.     public function setAllowProperties($allowProperties)
  425.     {
  426.         $this->allowProperties $allowProperties;
  427.     }
  428.     /**
  429.      * @return mixed
  430.      */
  431.     public function isAllowLinkedPages()
  432.     {
  433.         return $this->allowLinkedPages;
  434.     }
  435.     /**
  436.      * @param mixed $allowLinkedPages
  437.      */
  438.     public function setAllowLinkedPages($allowLinkedPages)
  439.     {
  440.         $this->allowLinkedPages = (bool)$allowLinkedPages;
  441.     }
  442.     /**
  443.      * @return bool
  444.      */
  445.     public function isDisableChangingPrice()
  446.     {
  447.         return $this->disableChangingPrice;
  448.     }
  449.     /**
  450.      * @param bool $disableChangingPrice
  451.      */
  452.     public function setDisableChangingPrice($disableChangingPrice)
  453.     {
  454.         $this->disableChangingPrice = (bool)$disableChangingPrice;
  455.     }
  456.     /**
  457.      * @return null|PageType
  458.      */
  459.     public function getLinkedPagesType()
  460.     {
  461.         return $this->linkedPagesType;
  462.     }
  463.     /**
  464.      * @param null|PageType $linkedPagesType
  465.      */
  466.     public function setLinkedPagesType(PageType $linkedPagesType null)
  467.     {
  468.         $this->linkedPagesType $linkedPagesType;
  469.     }
  470.     /**
  471.      * @return boolean
  472.      */
  473.     public function isProduct()
  474.     {
  475.         return $this->product;
  476.     }
  477.     /**
  478.      * @param boolean $product
  479.      */
  480.     public function setProduct($product)
  481.     {
  482.         $this->product $product;
  483.     }
  484.     /**
  485.      * @return string
  486.      */
  487.     public function getUrlMask()
  488.     {
  489.         return $this->urlMask;
  490.     }
  491.     /**
  492.      * @param string $urlMask
  493.      */
  494.     public function setUrlMask($urlMask)
  495.     {
  496.         $this->urlMask $urlMask;
  497.     }
  498. }