app/Plugin/CMBlogPro42/Entity/Blog.php line 20

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