Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace SoftUniBlogBundle\Entity;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\ORM\Mapping as ORM;
- /**
- * Article
- *
- * @ORM\Table(name="articles")
- * @ORM\Entity(repositoryClass="SoftUniBlogBundle\Repository\ArticleRepository")
- */
- class Article
- {
- /**
- * @var int
- *
- * @ORM\Column(name="id", type="integer")
- * @ORM\Id
- * @ORM\GeneratedValue(strategy="AUTO")
- */
- private $id;
- /**
- * @var string
- *
- * @ORM\Column(name="title", type="string", length=255)
- */
- private $title;
- /**
- * @var string
- *
- * @ORM\Column(name="content", type="text")
- */
- private $content;
- /**
- * @var \DateTime
- *
- * @ORM\Column(name="dateAdded", type="datetime")
- */
- private $dateAdded;
- /**
- * @var string
- */
- private $summary;
- /**
- * @param string
- */
- private function setSummary()
- {
- $this->summary = substr($this->getContent(), 0, strlen($this->getContent()) / 2) . "...";
- }
- /**
- * @return string
- */
- private function getSummary()
- {
- if ($this->summary === null)
- {
- $this->setSummary();
- }
- return $this->summary;
- }
- /**
- * @var int
- *
- * @ORM\Column(name="authorID", type="integer")
- */
- private $authorID;
- /**
- * @param integer $authorID
- *
- * @return Article
- */
- private function setAuthorID($authorID)
- {
- $this->authorID = $authorID;
- return $this;
- }
- /**
- * @return int
- */
- public function getAuthorID()
- {
- return $this->authorID;
- }
- /**
- * @var User
- *
- * @ORM\ManyToOne(targetEntity="SoftUniBlogBundle\Entity\User", inversedBy="articles")
- * @ORM\JoinColumn(name="authorID", referencedColumnName="id")
- */
- private $author;
- /**
- * @param \SoftUniBlogBundle\Entity\User $author
- *
- * @return Article
- */
- public function setAuthor(User $author = null)
- {
- $this->author = $author;
- return $this;
- }
- /**
- * @return \SoftUniBlogBundle\Entity\User
- */
- public function getAuthor()
- {
- return $this->author;
- }
- /**
- * Get id
- *
- * @return int
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set title
- *
- * @param string $title
- *
- * @return Article
- */
- public function setTitle($title)
- {
- $this->title = $title;
- return $this;
- }
- /**
- * Get title
- *
- * @return string
- */
- public function getTitle()
- {
- return $this->title;
- }
- /**
- * Set content
- *
- * @param string $content
- *
- * @return Article
- */
- public function setContent($content)
- {
- $this->content = $content;
- return $this;
- }
- /**
- * Get content
- *
- * @return string
- */
- public function getContent()
- {
- return $this->content;
- }
- /**
- * Set dateAdded
- *
- * @param \DateTime $dateAdded
- *
- * @return Article
- */
- public function setDateAdded($dateAdded)
- {
- $this->dateAdded = $dateAdded;
- return $this;
- }
- /**
- * Get dateAdded
- *
- * @return \DateTime
- */
- public function getDateAdded()
- {
- return $this->dateAdded;
- }
- public function __construct()
- {
- $this->dateAdded = new \DateTime('now');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement