<?php
/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Eccube\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
if (!class_exists('\Eccube\Entity\News')) {
/**
* News
*
* @ORM\Table(name="dtb_news")
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255)
* @ORM\HasLifecycleCallbacks()
* @ORM\Entity(repositoryClass="Eccube\Repository\NewsRepository")
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
*/
class News extends AbstractEntity
{
/**
* @return string
*/
public function __toString()
{
return (string) $this->getTitle();
}
public function getMainListImage()
{
$NewsImages = $this->getNewsImage();
return $NewsImages->isEmpty() ? null : $NewsImages[0];
}
public function getMainFileName()
{
if (count($this->NewsImage) > 0) {
return $this->NewsImage[0];
} else {
return null;
}
}
/**
* @var int
*
* @ORM\Column(name="id", type="integer", options={"unsigned":true})
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var \DateTime|null
*
* @ORM\Column(name="publish_date", type="datetimetz", nullable=true)
*/
private $publish_date;
/**
* @var string
*
* @ORM\Column(name="title", type="string", length=255)
*/
private $title;
/**
* @var string|null
*
* @ORM\Column(name="description", type="text", nullable=true)
*/
private $description;
/**
* @var string|null
*
* @ORM\Column(name="url", type="string", length=4000, nullable=true)
*/
private $url;
/**
* @var \Doctrine\Common\Collections\Collection
*
* @ORM\OneToMany(targetEntity="Eccube\Entity\NewsImage", mappedBy="News", cascade={"remove"})
* @ORM\OrderBy({
* "sort_no"="ASC"
* })
*/
private $NewsImage;
/**
* @var boolean
*
* @ORM\Column(name="link_method", type="boolean", options={"default":false})
*/
private $link_method = false;
/**
* @var \DateTime
*
* @ORM\Column(name="create_date", type="datetimetz")
*/
private $create_date;
/**
* @var \DateTime
*
* @ORM\Column(name="update_date", type="datetimetz")
*/
private $update_date;
/**
* @var boolean
*
* @ORM\Column(name="visible", type="boolean", options={"default":true})
*/
private $visible;
/**
* @var \Eccube\Entity\Member
*
* @ORM\ManyToOne(targetEntity="Eccube\Entity\Member")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="creator_id", referencedColumnName="id")
* })
*/
private $Creator;
/**
* Constructor
*/
public function __construct()
{
$this->NewsImage = new \Doctrine\Common\Collections\ArrayCollection();
}
public function copy()
{
$Images = $this->getNewsImage();
$this->NewsImage = new ArrayCollection();
foreach ($Images as $Image) {
$CloneImage = clone $Image;
$this->addNewsImage($CloneImage);
$CloneImage->setNews($this);
}
return $this;
}
/**
* Get id.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set publishDate.
*
* @param \DateTime|null $publishDate
*
* @return News
*/
public function setPublishDate($publishDate = null)
{
$this->publish_date = $publishDate;
return $this;
}
/**
* Get publishDate.
*
* @return \DateTime|null
*/
public function getPublishDate()
{
return $this->publish_date;
}
/**
* Set title.
*
* @param string $title
*
* @return News
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title.
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Add newsImage.
*
* @param \Eccube\Entity\NewsImage $newsImage
*
* @return News
*/
public function addNewsImage(NewsImage $newsImage)
{
$this->NewsImage[] = $newsImage;
return $this;
}
/**
* Remove newsImage.
*
* @param \Eccube\Entity\NewsImage $newsImage
*
* @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
*/
public function removeNewsImage(NewsImage $newsImage)
{
return $this->NewsImage->removeElement($newsImage);
}
/**
* Get newsImage.
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getNewsImage()
{
return $this->NewsImage;
}
/**
* Set description.
*
* @param string|null $description
*
* @return News
*/
public function setDescription($description = null)
{
$this->description = $description;
return $this;
}
/**
* Get description.
*
* @return string|null
*/
public function getDescription()
{
return $this->description;
}
/**
* Set url.
*
* @param string|null $url
*
* @return News
*/
public function setUrl($url = null)
{
$this->url = $url;
return $this;
}
/**
* Get url.
*
* @return string|null
*/
public function getUrl()
{
return $this->url;
}
/**
* Set linkMethod.
*
* @param boolean $linkMethod
*
* @return News
*/
public function setLinkMethod($linkMethod)
{
$this->link_method = $linkMethod;
return $this;
}
/**
* Get linkMethod.
*
* @return boolean
*/
public function isLinkMethod()
{
return $this->link_method;
}
/**
* Set createDate.
*
* @param \DateTime $createDate
*
* @return News
*/
public function setCreateDate($createDate)
{
$this->create_date = $createDate;
return $this;
}
/**
* Get createDate.
*
* @return \DateTime
*/
public function getCreateDate()
{
return $this->create_date;
}
/**
* Set updateDate.
*
* @param \DateTime $updateDate
*
* @return News
*/
public function setUpdateDate($updateDate)
{
$this->update_date = $updateDate;
return $this;
}
/**
* Get updateDate.
*
* @return \DateTime
*/
public function getUpdateDate()
{
return $this->update_date;
}
/**
* @return integer
*/
public function isVisible()
{
return $this->visible;
}
/**
* @param boolean $visible
*
* @return News
*/
public function setVisible($visible)
{
$this->visible = $visible;
return $this;
}
/**
* Set creator.
*
* @param \Eccube\Entity\Member|null $creator
*
* @return News
*/
public function setCreator(Member $creator = null)
{
$this->Creator = $creator;
return $this;
}
/**
* Get creator.
*
* @return \Eccube\Entity\Member|null
*/
public function getCreator()
{
return $this->Creator;
}
}
}