app/Plugin/CMBlogPro/Entity/Blog.php line 21

Open in your IDE?
  1. <?php
  2. namespace Plugin\CMBlogPro\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  7. if (!class_exists('\Plugin\CMBlogPro\Entity\Blog')) {
  8.     /**
  9.      * Blog
  10.      *
  11.      * @ORM\Table(name="plg_blog_data2")
  12.      * @ORM\InheritanceType("SINGLE_TABLE")
  13.      * @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255)
  14.      * @ORM\HasLifecycleCallbacks()
  15.      * @ORM\Entity(repositoryClass="Plugin\CMBlogPro\Repository\BlogRepository")
  16.      * @UniqueEntity("slug")
  17.      */
  18.     class Blog extends \Eccube\Entity\AbstractEntity
  19.     {
  20.         /**
  21.          * @return string
  22.          */
  23.         public function __toString()
  24.         {
  25.             return (string) $this->getName();
  26.         }
  27.         /**
  28.          * Is Enable
  29.          *
  30.          * @return bool
  31.          *
  32.          * @deprecated
  33.          */
  34.         public function isEnable()
  35.         {
  36.             return $this->getStatus()->getId() === \Plugin\CMBlogPro\Entity\BlogStatus::DISPLAY_SHOW true false;
  37.         }
  38.         public function getMainListImage()
  39.         {
  40.             $BlogImages $this->getBlogImage();
  41.             return empty($BlogImages) ? null $BlogImages[0];
  42.         }
  43.         public function getMainFileName()
  44.         {
  45.             if (count($this->BlogImage) > 0) {
  46.                 return $this->BlogImage[0];
  47.             } else {
  48.                 return null;
  49.             }
  50.         }
  51.         
  52.         /**
  53.          * @var int
  54.          *
  55.          * @ORM\Column(name="id", type="integer", options={"unsigned":true})
  56.          * @ORM\Id
  57.          * @ORM\GeneratedValue(strategy="IDENTITY")
  58.          */
  59.         private $id;
  60.         /**
  61.          * @var string
  62.          *
  63.          * @ORM\Column(name="title", type="string", length=200)
  64.          */
  65.         private $title;
  66.         /**
  67.          * @var string
  68.          *
  69.          * @ORM\Column(type="string", length=255, nullable=true, unique=true)
  70.          */
  71.         private $slug;
  72.         /**
  73.          * @var \Doctrine\Common\Collections\Collection
  74.          *
  75.          * @ORM\OneToMany(targetEntity="Plugin\CMBlogPro\Entity\BlogCategory", mappedBy="Blog", cascade={"persist","remove"})
  76.          */
  77.         private $BlogCategories;
  78.         /**
  79.          * @var \Doctrine\Common\Collections\Collection
  80.          *
  81.          * @ORM\OneToMany(targetEntity="Plugin\CMBlogPro\Entity\BlogImage", mappedBy="Blog", cascade={"remove"})
  82.          * @ORM\OrderBy({
  83.          *     "sort_no"="ASC"
  84.          * })
  85.          */
  86.         private $BlogImage;
  87.         /**
  88.          * @var \Doctrine\Common\Collections\Collection
  89.          *
  90.          * @ORM\OneToMany(targetEntity="Plugin\CMBlogPro\Entity\BlogProduct", mappedBy="Blog", cascade={"persist","remove"})
  91.          */
  92.         private $BlogProduct;
  93.         /**
  94.          * @var text|null
  95.          *
  96.          * @ORM\Column(name="body", type="text", nullable=true)
  97.          */
  98.         private $body;
  99.         /**
  100.          * @var string|null
  101.          *
  102.          * @ORM\Column(name="author", type="string", length=255, nullable=true)
  103.          */
  104.         private $author;
  105.         /**
  106.          * @var string|null
  107.          *
  108.          * @ORM\Column(name="description", type="string", length=255, nullable=true)
  109.          */
  110.         private $description;
  111.         /**
  112.          * @var string|null
  113.          *
  114.          * @ORM\Column(name="keyword", type="string", length=255, nullable=true)
  115.          */
  116.         private $keyword;
  117.         /**
  118.          * @var string|null
  119.          *
  120.          * @ORM\Column(name="meta_robots", type="string", length=255, nullable=true)
  121.          */
  122.         private $robot;
  123.         /**
  124.          * @var string|null
  125.          *
  126.          * @ORM\Column(name="meta_tags", type="text", nullable=true)
  127.          */
  128.         private $metatag;
  129.         /**
  130.          * @var \DateTime
  131.          *
  132.          * @ORM\Column(name="release_date", type="datetime", nullable=true)
  133.          */
  134.         private $release_date;
  135.         /**
  136.          * @var \DateTime
  137.          *
  138.          * @ORM\Column(name="create_date", type="datetime")
  139.          */
  140.         private $create_date;
  141.         /**
  142.          * @var \DateTime
  143.          *
  144.          * @ORM\Column(name="update_date", type="datetime")
  145.          */
  146.         private $update_date;
  147.         /**
  148.          * @var \Eccube\Entity\Member
  149.          *
  150.          * @ORM\ManyToOne(targetEntity="Eccube\Entity\Member")
  151.          * @ORM\JoinColumns({
  152.          *   @ORM\JoinColumn(name="creator_id", referencedColumnName="id")
  153.          * })
  154.          */
  155.         private $Creator;
  156.         /**
  157.          * @var \Plugin\CMBlogPro\Entity\BlogStatus
  158.          *
  159.          * @ORM\ManyToOne(targetEntity="Plugin\CMBlogPro\Entity\BlogStatus")
  160.          * @ORM\JoinColumns({
  161.          *   @ORM\JoinColumn(name="blog_status_id", referencedColumnName="id")
  162.          * })
  163.          */
  164.         private $Status;
  165.         /**
  166.          * @var tag|null
  167.          *
  168.          * @ORM\Column(name="tag", type="text", nullable=true)
  169.          */
  170.         private $tag;
  171.         /**
  172.          * Constructor
  173.          */
  174.         public function __construct()
  175.         {
  176.             $this->BlogCategories = new \Doctrine\Common\Collections\ArrayCollection();
  177.             $this->BlogProduct = new \Doctrine\Common\Collections\ArrayCollection();
  178.             $this->BlogImage = new \Doctrine\Common\Collections\ArrayCollection();
  179.         }
  180.         public function __clone()
  181.         {
  182.             $this->id null;
  183.         }
  184.         public function copy()
  185.         {
  186.             // コピー対象外
  187.             $Categories $this->getBlogCategories();
  188.             $this->BlogCategories = new ArrayCollection();
  189.             foreach ($Categories as $Category) {
  190.                 $CopyCategory = clone $Category;
  191.                 $this->addBlogCategory($CopyCategory);
  192.                 $CopyCategory->setBlog($this);
  193.             }
  194.             $Products $this->getBlogProduct();
  195.             $this->BlogProduct = new ArrayCollection();
  196.             foreach ($Products as $Product) {
  197.                 $CopyProduct = clone $Product;
  198.                 $this->addBlogProduct($CopyProduct);
  199.                 $CopyProduct->setBlog($this);
  200.             }
  201.             $Images $this->getBlogImage();
  202.             $this->BlogImage = new ArrayCollection();
  203.             foreach ($Images as $Image) {
  204.                 $CloneImage = clone $Image;
  205.                 $this->addBlogImage($CloneImage);
  206.                 $CloneImage->setBlog($this);
  207.             }
  208.             return $this;
  209.         }
  210.         /**
  211.          * @return int
  212.          */
  213.         public function getId()
  214.         {
  215.             return $this->id;
  216.         }
  217.         /**
  218.          * @return string
  219.          */
  220.         public function getTitle()
  221.         {
  222.             return $this->title;
  223.         }
  224.         /**
  225.          * @param string $title
  226.          *
  227.          * @return Blog;
  228.          */
  229.         public function setTitle($title)
  230.         {
  231.             $this->title $title;
  232.             return $this;
  233.         }
  234.         /**
  235.          * @return string
  236.          */
  237.         public function getSlug()
  238.         {
  239.             return $this->slug;
  240.         }
  241.         /**
  242.          * @param string $slug
  243.          *
  244.          * @return Blog;
  245.          */
  246.         public function setSlug($slug)
  247.         {
  248.             $this->slug $slug;
  249.             return $this;
  250.         }
  251.         /**
  252.          * Add blogCategory.
  253.          *
  254.          * @param \Plugin\CMBlogPro\Entity\BlogCategory $blogCategory
  255.          *
  256.          * @return Blog
  257.          */
  258.         public function addBlogCategory(\Plugin\CMBlogPro\Entity\BlogCategory $blogCategory)
  259.         {
  260.             $this->BlogCategories[] = $blogCategory;
  261.             return $this;
  262.         }
  263.         /**
  264.          * Remove blogCategory.
  265.          *
  266.          * @param \Plugin\CMBlogPro\Entity\BlogCategory $blogCategory
  267.          *
  268.          * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
  269.          */
  270.         public function removeBlogCategory(\Plugin\CMBlogPro\Entity\BlogCategory $blogCategory)
  271.         {
  272.             return $this->BlogCategories->removeElement($blogCategory);
  273.         }
  274.         /**
  275.          * Get blogCategories.
  276.          *
  277.          * @return \Doctrine\Common\Collections\Collection
  278.          */
  279.         public function getBlogCategories()
  280.         {
  281.             return $this->BlogCategories;
  282.         }
  283.         /**
  284.          * Add blogProduct.
  285.          *
  286.          * @param \Plugin\CMBlogPro\Entity\BlogProduct $blogProduct
  287.          *
  288.          * @return Blog
  289.          */
  290.         public function addBlogProduct(\Plugin\CMBlogPro\Entity\BlogProduct $blogProduct)
  291.         {
  292.             $this->BlogProduct[] = $blogProduct;
  293.             return $this;
  294.         }
  295.         /**
  296.          * Remove blogProduct.
  297.          *
  298.          * @param \Plugin\CMBlogPro\Entity\BlogProduct $blogProduct
  299.          *
  300.          * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
  301.          */
  302.         public function removeBlogProduct(\Plugin\CMBlogPro\Entity\BlogProduct $blogProduct)
  303.         {
  304.             return $this->BlogProduct->removeElement($blogProduct);
  305.         }
  306.         /**
  307.          * Get blogProduct.
  308.          *
  309.          * @return \Doctrine\Common\Collections\Collection
  310.          */
  311.         public function getBlogProduct()
  312.         {
  313.             return $this->BlogProduct;
  314.         }
  315.          /**
  316.          * Add blogImage.
  317.          *
  318.          * @param \Plugin\CMBlogPro\Entity\BlogImage $blogImage
  319.          *
  320.          * @return Blog
  321.          */
  322.         public function addBlogImage(\Plugin\CMBlogPro\Entity\BlogImage $blogImage)
  323.         {
  324.             $this->BlogImage[] = $blogImage;
  325.             return $this;
  326.         }
  327.         /**
  328.          * Remove blogImage.
  329.          *
  330.          * @param \Plugin\CMBlogPro\Entity\BlogImage $blogImage
  331.          *
  332.          * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
  333.          */
  334.         public function removeBlogImage(\Plugin\CMBlogPro\Entity\BlogImage $blogImage)
  335.         {
  336.             return $this->BlogImage->removeElement($blogImage);
  337.         }
  338.         /**
  339.          * Get blogImage.
  340.          *
  341.          * @return \Doctrine\Common\Collections\Collection
  342.          */
  343.         public function getBlogImage()
  344.         {
  345.             return $this->BlogImage;
  346.         }
  347.         /**
  348.          * @return string
  349.          */
  350.         public function getBody()
  351.         {
  352.             return $this->body;
  353.         }
  354.         /**
  355.          * @param string $body
  356.          *
  357.          * @return Blog;
  358.          */
  359.         public function setBody($body)
  360.         {
  361.             $this->body $body;
  362.             return $this;
  363.         }
  364.         /**
  365.          * @return string
  366.          */
  367.         public function getAuthor()
  368.         {
  369.             return $this->author;
  370.         }
  371.         /**
  372.          * @param string $author
  373.          *
  374.          * @return Blog;
  375.          */
  376.         public function setAuthor($author)
  377.         {
  378.             $this->author $author;
  379.             return $this;
  380.         }
  381.         /**
  382.          * @return string
  383.          */
  384.         public function getDescription()
  385.         {
  386.             return $this->description;
  387.         }
  388.         /**
  389.          * @param string $description
  390.          *
  391.          * @return Blog;
  392.          */
  393.         public function setDescription($description)
  394.         {
  395.             $this->description $description;
  396.             return $this;
  397.         }
  398.         /**
  399.          * @return string
  400.          */
  401.         public function getKeyword()
  402.         {
  403.             return $this->keyword;
  404.         }
  405.         /**
  406.          * @param string $keyword
  407.          *
  408.          * @return Blog;
  409.          */
  410.         public function setKeyword($keyword)
  411.         {
  412.             $this->keyword $keyword;
  413.             return $this;
  414.         }
  415.         /**
  416.          * @return string
  417.          */
  418.         public function getRobot()
  419.         {
  420.             return $this->robot;
  421.         }
  422.         /**
  423.          * @param string $robot
  424.          *
  425.          * @return Blog;
  426.          */
  427.         public function setRobot($robot)
  428.         {
  429.             $this->robot $robot;
  430.             return $this;
  431.         }
  432.         /**
  433.          * @return string
  434.          */
  435.         public function getMetatag()
  436.         {
  437.             return $this->metatag;
  438.         }
  439.         /**
  440.          * @param string $metatag
  441.          *
  442.          * @return Blog;
  443.          */
  444.         public function setMetatag($metatag)
  445.         {
  446.             $this->metatag $metatag;
  447.             return $this;
  448.         }
  449.         /**
  450.          * Set releaseDate.
  451.          *
  452.          * @param \DateTime $releaseDate
  453.          *
  454.          * @return Blog
  455.          */
  456.         public function setReleaseDate($releaseDate)
  457.         {
  458.             $this->release_date $releaseDate;
  459.             return $this;
  460.         }
  461.         /**
  462.          * Get releaseDate.
  463.          *
  464.          * @return \DateTime
  465.          */
  466.         public function getReleaseDate()
  467.         {
  468.             return $this->release_date;
  469.         }
  470.         /**
  471.          * Set createDate.
  472.          *
  473.          * @param \DateTime $createDate
  474.          *
  475.          * @return Blog
  476.          */
  477.         public function setCreateDate($createDate)
  478.         {
  479.             $this->create_date $createDate;
  480.             return $this;
  481.         }
  482.         /**
  483.          * Get createDate.
  484.          *
  485.          * @return \DateTime
  486.          */
  487.         public function getCreateDate()
  488.         {
  489.             return $this->create_date;
  490.         }
  491.         /**
  492.          * Set updateDate.
  493.          *
  494.          * @param \DateTime $updateDate
  495.          *
  496.          * @return Blog
  497.          */
  498.         public function setUpdateDate($updateDate)
  499.         {
  500.             $this->update_date $updateDate;
  501.             return $this;
  502.         }
  503.         /**
  504.          * Get updateDate.
  505.          *
  506.          * @return \DateTime
  507.          */
  508.         public function getUpdateDate()
  509.         {
  510.             return $this->update_date;
  511.         }
  512.         /**
  513.          * Set creator.
  514.          *
  515.          * @param \Eccube\Entity\Member|null $creator
  516.          *
  517.          * @return Blog
  518.          */
  519.         public function setCreator(\Eccube\Entity\Member $creator null)
  520.         {
  521.             $this->Creator $creator;
  522.             return $this;
  523.         }
  524.         /**
  525.          * Get creator.
  526.          *
  527.          * @return \Eccube\Entity\Member|null
  528.          */
  529.         public function getCreator()
  530.         {
  531.             return $this->Creator;
  532.         }
  533.         /**
  534.          * Set status.
  535.          *
  536.          * @param \Plugin\CMBlogPro\Entity\BlogStatus|null $status
  537.          *
  538.          * @return Blog
  539.          */
  540.         public function setStatus(\Plugin\CMBlogPro\Entity\BlogStatus $status null)
  541.         {
  542.             $this->Status $status;
  543.             return $this;
  544.         }
  545.         /**
  546.          * Get status.
  547.          *
  548.          * @return \Plugin\CMBlogPro\Entity\BlogStatus|null
  549.          */
  550.         public function getStatus()
  551.         {
  552.             return $this->Status;
  553.         }
  554.         /**
  555.          * @return string
  556.          */
  557.         public function getTag()
  558.         {
  559.             return $this->tag;
  560.         }
  561.         /**
  562.          * @param string $tag
  563.          *
  564.          * @return Blog;
  565.          */
  566.         public function setTag($tag)
  567.         {
  568.             $this->tag $tag;
  569.             return $this;
  570.         }
  571.     }
  572. }