src/Eccube/Entity/News.php line 30

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\Common\Collections\ArrayCollection;
  14. use Doctrine\ORM\Mapping as ORM;
  15. if (!class_exists('\Eccube\Entity\News')) {
  16.     /**
  17.      * News
  18.      *
  19.      * @ORM\Table(name="dtb_news")
  20.      * @ORM\InheritanceType("SINGLE_TABLE")
  21.      * @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255)
  22.      * @ORM\HasLifecycleCallbacks()
  23.      * @ORM\Entity(repositoryClass="Eccube\Repository\NewsRepository")
  24.      * @ORM\Cache(usage="NONSTRICT_READ_WRITE")
  25.      */
  26.     class News extends AbstractEntity
  27.     {
  28.         /**
  29.          * @return string
  30.          */
  31.         public function __toString()
  32.         {
  33.             return (string) $this->getTitle();
  34.         }
  35.         public function getMainListImage()
  36.         {
  37.             $NewsImages $this->getNewsImage();
  38.             return $NewsImages->isEmpty() ? null $NewsImages[0];
  39.         }
  40.         public function getMainFileName()
  41.         {
  42.             if (count($this->NewsImage) > 0) {
  43.                 return $this->NewsImage[0];
  44.             } else {
  45.                 return null;
  46.             }
  47.         }
  48.         /**
  49.          * @var int
  50.          *
  51.          * @ORM\Column(name="id", type="integer", options={"unsigned":true})
  52.          * @ORM\Id
  53.          * @ORM\GeneratedValue(strategy="IDENTITY")
  54.          */
  55.         private $id;
  56.         /**
  57.          * @var \DateTime|null
  58.          *
  59.          * @ORM\Column(name="publish_date", type="datetimetz", nullable=true)
  60.          */
  61.         private $publish_date;
  62.         /**
  63.          * @var string
  64.          *
  65.          * @ORM\Column(name="title", type="string", length=255)
  66.          */
  67.         private $title;
  68.         /**
  69.          * @var string|null
  70.          *
  71.          * @ORM\Column(name="description", type="text", nullable=true)
  72.          */
  73.         private $description;
  74.         /**
  75.          * @var string|null
  76.          *
  77.          * @ORM\Column(name="url", type="string", length=4000, nullable=true)
  78.          */
  79.         private $url;
  80.         /**
  81.          * @var \Doctrine\Common\Collections\Collection
  82.          *
  83.          * @ORM\OneToMany(targetEntity="Eccube\Entity\NewsImage", mappedBy="News", cascade={"remove"})
  84.          * @ORM\OrderBy({
  85.          *     "sort_no"="ASC"
  86.          * })
  87.          */
  88.         private $NewsImage;
  89.         /**
  90.          * @var boolean
  91.          *
  92.          * @ORM\Column(name="link_method", type="boolean", options={"default":false})
  93.          */
  94.         private $link_method false;
  95.         /**
  96.          * @var \DateTime
  97.          *
  98.          * @ORM\Column(name="create_date", type="datetimetz")
  99.          */
  100.         private $create_date;
  101.         /**
  102.          * @var \DateTime
  103.          *
  104.          * @ORM\Column(name="update_date", type="datetimetz")
  105.          */
  106.         private $update_date;
  107.         /**
  108.          * @var boolean
  109.          *
  110.          * @ORM\Column(name="visible", type="boolean", options={"default":true})
  111.          */
  112.         private $visible;
  113.         /**
  114.          * @var \Eccube\Entity\Member
  115.          *
  116.          * @ORM\ManyToOne(targetEntity="Eccube\Entity\Member")
  117.          * @ORM\JoinColumns({
  118.          *   @ORM\JoinColumn(name="creator_id", referencedColumnName="id")
  119.          * })
  120.          */
  121.         private $Creator;
  122.         /**
  123.          * Constructor
  124.          */
  125.         public function __construct()
  126.         {
  127.             $this->NewsImage = new \Doctrine\Common\Collections\ArrayCollection();
  128.         }
  129.         public function copy()
  130.         {
  131.             $Images $this->getNewsImage();
  132.             $this->NewsImage = new ArrayCollection();
  133.             foreach ($Images as $Image) {
  134.                 $CloneImage = clone $Image;
  135.                 $this->addNewsImage($CloneImage);
  136.                 $CloneImage->setNews($this);
  137.             }
  138.             return $this;
  139.         }
  140.         /**
  141.          * Get id.
  142.          *
  143.          * @return int
  144.          */
  145.         public function getId()
  146.         {
  147.             return $this->id;
  148.         }
  149.         /**
  150.          * Set publishDate.
  151.          *
  152.          * @param \DateTime|null $publishDate
  153.          *
  154.          * @return News
  155.          */
  156.         public function setPublishDate($publishDate null)
  157.         {
  158.             $this->publish_date $publishDate;
  159.             return $this;
  160.         }
  161.         /**
  162.          * Get publishDate.
  163.          *
  164.          * @return \DateTime|null
  165.          */
  166.         public function getPublishDate()
  167.         {
  168.             return $this->publish_date;
  169.         }
  170.         /**
  171.          * Set title.
  172.          *
  173.          * @param string $title
  174.          *
  175.          * @return News
  176.          */
  177.         public function setTitle($title)
  178.         {
  179.             $this->title $title;
  180.             return $this;
  181.         }
  182.         /**
  183.          * Get title.
  184.          *
  185.          * @return string
  186.          */
  187.         public function getTitle()
  188.         {
  189.             return $this->title;
  190.         }
  191.         /**
  192.          * Add newsImage.
  193.          *
  194.          * @param \Eccube\Entity\NewsImage $newsImage
  195.          *
  196.          * @return News
  197.          */
  198.         public function addNewsImage(NewsImage $newsImage)
  199.         {
  200.             $this->NewsImage[] = $newsImage;
  201.             return $this;
  202.         }
  203.         /**
  204.          * Remove newsImage.
  205.          *
  206.          * @param \Eccube\Entity\NewsImage $newsImage
  207.          *
  208.          * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
  209.          */
  210.         public function removeNewsImage(NewsImage $newsImage)
  211.         {
  212.             return $this->NewsImage->removeElement($newsImage);
  213.         }
  214.         /**
  215.          * Get newsImage.
  216.          *
  217.          * @return \Doctrine\Common\Collections\Collection
  218.          */
  219.         public function getNewsImage()
  220.         {
  221.             return $this->NewsImage;
  222.         }
  223.         /**
  224.          * Set description.
  225.          *
  226.          * @param string|null $description
  227.          *
  228.          * @return News
  229.          */
  230.         public function setDescription($description null)
  231.         {
  232.             $this->description $description;
  233.             return $this;
  234.         }
  235.         /**
  236.          * Get description.
  237.          *
  238.          * @return string|null
  239.          */
  240.         public function getDescription()
  241.         {
  242.             return $this->description;
  243.         }
  244.         /**
  245.          * Set url.
  246.          *
  247.          * @param string|null $url
  248.          *
  249.          * @return News
  250.          */
  251.         public function setUrl($url null)
  252.         {
  253.             $this->url $url;
  254.             return $this;
  255.         }
  256.         /**
  257.          * Get url.
  258.          *
  259.          * @return string|null
  260.          */
  261.         public function getUrl()
  262.         {
  263.             return $this->url;
  264.         }
  265.         /**
  266.          * Set linkMethod.
  267.          *
  268.          * @param boolean $linkMethod
  269.          *
  270.          * @return News
  271.          */
  272.         public function setLinkMethod($linkMethod)
  273.         {
  274.             $this->link_method $linkMethod;
  275.             return $this;
  276.         }
  277.         /**
  278.          * Get linkMethod.
  279.          *
  280.          * @return boolean
  281.          */
  282.         public function isLinkMethod()
  283.         {
  284.             return $this->link_method;
  285.         }
  286.         /**
  287.          * Set createDate.
  288.          *
  289.          * @param \DateTime $createDate
  290.          *
  291.          * @return News
  292.          */
  293.         public function setCreateDate($createDate)
  294.         {
  295.             $this->create_date $createDate;
  296.             return $this;
  297.         }
  298.         /**
  299.          * Get createDate.
  300.          *
  301.          * @return \DateTime
  302.          */
  303.         public function getCreateDate()
  304.         {
  305.             return $this->create_date;
  306.         }
  307.         /**
  308.          * Set updateDate.
  309.          *
  310.          * @param \DateTime $updateDate
  311.          *
  312.          * @return News
  313.          */
  314.         public function setUpdateDate($updateDate)
  315.         {
  316.             $this->update_date $updateDate;
  317.             return $this;
  318.         }
  319.         /**
  320.          * Get updateDate.
  321.          *
  322.          * @return \DateTime
  323.          */
  324.         public function getUpdateDate()
  325.         {
  326.             return $this->update_date;
  327.         }
  328.         /**
  329.          * @return integer
  330.          */
  331.         public function isVisible()
  332.         {
  333.             return $this->visible;
  334.         }
  335.         /**
  336.          * @param boolean $visible
  337.          *
  338.          * @return News
  339.          */
  340.         public function setVisible($visible)
  341.         {
  342.             $this->visible $visible;
  343.             return $this;
  344.         }
  345.         /**
  346.          * Set creator.
  347.          *
  348.          * @param \Eccube\Entity\Member|null $creator
  349.          *
  350.          * @return News
  351.          */
  352.         public function setCreator(Member $creator null)
  353.         {
  354.             $this->Creator $creator;
  355.             return $this;
  356.         }
  357.         /**
  358.          * Get creator.
  359.          *
  360.          * @return \Eccube\Entity\Member|null
  361.          */
  362.         public function getCreator()
  363.         {
  364.             return $this->Creator;
  365.         }
  366.     }
  367. }