src/Eccube/Entity/Page.php line 28

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.ec-cube.co.jp/
  8.  *
  9.  * For the full copyright and license information, please view the LICENSE
  10.  * file that was distributed with this source code.
  11.  */
  12. namespace Eccube\Entity;
  13. use Doctrine\ORM\Mapping as ORM;
  14. if (!class_exists('\Eccube\Entity\Page')) {
  15.     /**
  16.      * Page
  17.      *
  18.      * @ORM\Table(name="dtb_page", indexes={@ORM\Index(name="dtb_page_url_idx", columns={"url"})})
  19.      * @ORM\InheritanceType("SINGLE_TABLE")
  20.      * @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255)
  21.      * @ORM\HasLifecycleCallbacks()
  22.      * @ORM\Entity(repositoryClass="Eccube\Repository\PageRepository")
  23.      */
  24.     class Page extends \Eccube\Entity\AbstractEntity
  25.     {
  26.         // 編集可能フラグ
  27.         public const EDIT_TYPE_USER 0;
  28.         public const EDIT_TYPE_PREVIEW 1;
  29.         public const EDIT_TYPE_DEFAULT 2;
  30.         public const EDIT_TYPE_DEFAULT_CONFIRM 3;
  31.         // 特定商取引法ページID
  32.         public const TRADELAW_PAGE_ID 21;
  33.         // ご利用規約ページID
  34.         public const AGREEMENT_PAGE_ID 19;
  35.         public function getLayouts()
  36.         {
  37.             $Layouts = [];
  38.             foreach ($this->PageLayouts as $PageLayout) {
  39.                 $Layouts[] = $PageLayout->getLayout();
  40.             }
  41.             return $Layouts;
  42.         }
  43.         /**
  44.          * @var int
  45.          *
  46.          * @ORM\Column(name="id", type="integer", options={"unsigned":true})
  47.          * @ORM\Id
  48.          * @ORM\GeneratedValue(strategy="IDENTITY")
  49.          */
  50.         private $id;
  51.         /**
  52.          * @var string|null
  53.          *
  54.          * @ORM\Column(name="page_name", type="string", length=255, nullable=true)
  55.          */
  56.         private $name;
  57.         /**
  58.          * @var string
  59.          *
  60.          * @ORM\Column(name="url", type="string", length=255)
  61.          */
  62.         private $url;
  63.         /**
  64.          * @var string|null
  65.          *
  66.          * @ORM\Column(name="file_name", type="string", length=255, nullable=true)
  67.          */
  68.         private $file_name;
  69.         /**
  70.          * @var int
  71.          *
  72.          * @ORM\Column(name="edit_type", type="smallint", options={"unsigned":true,"default":1})
  73.          */
  74.         private $edit_type 1;
  75.         /**
  76.          * @var string|null
  77.          *
  78.          * @ORM\Column(name="author", type="string", length=255, nullable=true)
  79.          */
  80.         private $author;
  81.         /**
  82.          * @var string|null
  83.          *
  84.          * @ORM\Column(name="description", type="string", length=255, nullable=true)
  85.          */
  86.         private $description;
  87.         /**
  88.          * @var string|null
  89.          *
  90.          * @ORM\Column(name="keyword", type="string", length=255, nullable=true)
  91.          */
  92.         private $keyword;
  93.         /**
  94.          * @var \DateTime
  95.          *
  96.          * @ORM\Column(name="create_date", type="datetimetz")
  97.          */
  98.         private $create_date;
  99.         /**
  100.          * @var \DateTime
  101.          *
  102.          * @ORM\Column(name="update_date", type="datetimetz")
  103.          */
  104.         private $update_date;
  105.         /**
  106.          * @var string|null
  107.          *
  108.          * @ORM\Column(name="meta_robots", type="string", length=255, nullable=true)
  109.          */
  110.         private $meta_robots;
  111.         /**
  112.          * @var string|null
  113.          *
  114.          * @ORM\Column(name="meta_tags", type="string", length=4000, nullable=true)
  115.          */
  116.         private $meta_tags;
  117.         /**
  118.          * @var \Doctrine\Common\Collections\Collection
  119.          *
  120.          * @ORM\OneToMany(targetEntity="Eccube\Entity\PageLayout", mappedBy="Page", cascade={"persist","remove"})
  121.          */
  122.         private $PageLayouts;
  123.         /**
  124.          * @var \Eccube\Entity\Page
  125.          *
  126.          * @ORM\ManyToOne(targetEntity="Eccube\Entity\Page")
  127.          * @ORM\JoinColumns({
  128.          *   @ORM\JoinColumn(name="master_page_id", referencedColumnName="id")
  129.          * })
  130.          */
  131.         private $MasterPage;
  132.         /**
  133.          * Constructor
  134.          */
  135.         public function __construct()
  136.         {
  137.             $this->PageLayouts = new \Doctrine\Common\Collections\ArrayCollection();
  138.         }
  139.         /**
  140.          * Set id
  141.          *
  142.          * @return Page
  143.          */
  144.         public function setId($id)
  145.         {
  146.             $this->id $id;
  147.             return $this;
  148.         }
  149.         /**
  150.          * Get id
  151.          *
  152.          * @return integer
  153.          */
  154.         public function getId()
  155.         {
  156.             return $this->id;
  157.         }
  158.         /**
  159.          * Set name.
  160.          *
  161.          * @param string|null $name
  162.          *
  163.          * @return Page
  164.          */
  165.         public function setName($name null)
  166.         {
  167.             $this->name $name;
  168.             return $this;
  169.         }
  170.         /**
  171.          * Get name.
  172.          *
  173.          * @return string|null
  174.          */
  175.         public function getName()
  176.         {
  177.             return $this->name;
  178.         }
  179.         /**
  180.          * Set url.
  181.          *
  182.          * @param string $url
  183.          *
  184.          * @return Page
  185.          */
  186.         public function setUrl($url)
  187.         {
  188.             $this->url $url;
  189.             return $this;
  190.         }
  191.         /**
  192.          * Get url.
  193.          *
  194.          * @return string
  195.          */
  196.         public function getUrl()
  197.         {
  198.             return $this->url;
  199.         }
  200.         /**
  201.          * Set fileName.
  202.          *
  203.          * @param string|null $fileName
  204.          *
  205.          * @return Page
  206.          */
  207.         public function setFileName($fileName null)
  208.         {
  209.             $this->file_name $fileName;
  210.             return $this;
  211.         }
  212.         /**
  213.          * Get fileName.
  214.          *
  215.          * @return string|null
  216.          */
  217.         public function getFileName()
  218.         {
  219.             return $this->file_name;
  220.         }
  221.         /**
  222.          * Set editType.
  223.          *
  224.          * @param int $editType
  225.          *
  226.          * @return Page
  227.          */
  228.         public function setEditType($editType)
  229.         {
  230.             $this->edit_type $editType;
  231.             return $this;
  232.         }
  233.         /**
  234.          * Get editType.
  235.          *
  236.          * @return int
  237.          */
  238.         public function getEditType()
  239.         {
  240.             return $this->edit_type;
  241.         }
  242.         /**
  243.          * Set author.
  244.          *
  245.          * @param string|null $author
  246.          *
  247.          * @return Page
  248.          */
  249.         public function setAuthor($author null)
  250.         {
  251.             $this->author $author;
  252.             return $this;
  253.         }
  254.         /**
  255.          * Get author.
  256.          *
  257.          * @return string|null
  258.          */
  259.         public function getAuthor()
  260.         {
  261.             return $this->author;
  262.         }
  263.         /**
  264.          * Set description.
  265.          *
  266.          * @param string|null $description
  267.          *
  268.          * @return Page
  269.          */
  270.         public function setDescription($description null)
  271.         {
  272.             $this->description $description;
  273.             return $this;
  274.         }
  275.         /**
  276.          * Get description.
  277.          *
  278.          * @return string|null
  279.          */
  280.         public function getDescription()
  281.         {
  282.             return $this->description;
  283.         }
  284.         /**
  285.          * Set keyword.
  286.          *
  287.          * @param string|null $keyword
  288.          *
  289.          * @return Page
  290.          */
  291.         public function setKeyword($keyword null)
  292.         {
  293.             $this->keyword $keyword;
  294.             return $this;
  295.         }
  296.         /**
  297.          * Get keyword.
  298.          *
  299.          * @return string|null
  300.          */
  301.         public function getKeyword()
  302.         {
  303.             return $this->keyword;
  304.         }
  305.         /**
  306.          * Set createDate.
  307.          *
  308.          * @param \DateTime $createDate
  309.          *
  310.          * @return Page
  311.          */
  312.         public function setCreateDate($createDate)
  313.         {
  314.             $this->create_date $createDate;
  315.             return $this;
  316.         }
  317.         /**
  318.          * Get createDate.
  319.          *
  320.          * @return \DateTime
  321.          */
  322.         public function getCreateDate()
  323.         {
  324.             return $this->create_date;
  325.         }
  326.         /**
  327.          * Set updateDate.
  328.          *
  329.          * @param \DateTime $updateDate
  330.          *
  331.          * @return Page
  332.          */
  333.         public function setUpdateDate($updateDate)
  334.         {
  335.             $this->update_date $updateDate;
  336.             return $this;
  337.         }
  338.         /**
  339.          * Get updateDate.
  340.          *
  341.          * @return \DateTime
  342.          */
  343.         public function getUpdateDate()
  344.         {
  345.             return $this->update_date;
  346.         }
  347.         /**
  348.          * Set metaRobots.
  349.          *
  350.          * @param string|null $metaRobots
  351.          *
  352.          * @return Page
  353.          */
  354.         public function setMetaRobots($metaRobots null)
  355.         {
  356.             $this->meta_robots $metaRobots;
  357.             return $this;
  358.         }
  359.         /**
  360.          * Get metaRobots.
  361.          *
  362.          * @return string|null
  363.          */
  364.         public function getMetaRobots()
  365.         {
  366.             return $this->meta_robots;
  367.         }
  368.         /**
  369.          * Set meta_tags
  370.          *
  371.          * @param string $metaTags
  372.          *
  373.          * @return Page
  374.          */
  375.         public function setMetaTags($metaTags)
  376.         {
  377.             $this->meta_tags $metaTags;
  378.             return $this;
  379.         }
  380.         /**
  381.          * Get meta_tags
  382.          *
  383.          * @return string
  384.          */
  385.         public function getMetaTags()
  386.         {
  387.             return $this->meta_tags;
  388.         }
  389.         /**
  390.          * Get pageLayoutLayout.
  391.          *
  392.          * @return \Doctrine\Common\Collections\Collection
  393.          */
  394.         public function getPageLayouts()
  395.         {
  396.             return $this->PageLayouts;
  397.         }
  398.         /**
  399.          * Add pageLayoutLayout
  400.          *
  401.          * @param \Eccube\Entity\PageLayout $PageLayout
  402.          *
  403.          * @return Page
  404.          */
  405.         public function addPageLayout(PageLayout $PageLayout)
  406.         {
  407.             $this->PageLayouts[] = $PageLayout;
  408.             return $this;
  409.         }
  410.         /**
  411.          * Remove pageLayoutLayout
  412.          *
  413.          * @param \Eccube\Entity\PageLayout $PageLayout
  414.          */
  415.         public function removePageLayout(PageLayout $PageLayout)
  416.         {
  417.             $this->PageLayouts->removeElement($PageLayout);
  418.         }
  419.         /**
  420.          * Set MasterPage.
  421.          *
  422.          * @param \Eccube\Entity\Page|null $page
  423.          *
  424.          * @return Page
  425.          */
  426.         public function setMasterPage(Page $page null)
  427.         {
  428.             $this->MasterPage $page;
  429.             return $this;
  430.         }
  431.         /**
  432.          * Get MasterPage.
  433.          *
  434.          * @return \Eccube\Entity\Page|null
  435.          */
  436.         public function getMasterPage()
  437.         {
  438.             return $this->MasterPage;
  439.         }
  440.         /**
  441.          * @param $layoutId
  442.          *
  443.          * @return int|null
  444.          */
  445.         public function getSortNo($layoutId)
  446.         {
  447.             $pageLayouts $this->getPageLayouts();
  448.             /** @var PageLayout $pageLayout */
  449.             foreach ($pageLayouts as $pageLayout) {
  450.                 if ($pageLayout->getLayoutId() == $layoutId) {
  451.                     return $pageLayout->getSortNo();
  452.                 }
  453.             }
  454.             return null;
  455.         }
  456.     }
  457. }