Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace SoftUniBlogBundle\Entity;
- 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 int
- *
- * @ORM\Column(name="authorId", type="integer")
- */
- private $authorId;
- /**
- * @var User
- *
- * @ORM\ManyToOne(targetEntity="SoftUniBlogBundle\Entity\User", inversedBy="articles")
- * @ORM\JoinColumn(name="authorId", referencedColumnName="id")
- */
- private $author;
- /**
- * Article constructor.
- */
- public function __construct()
- {
- $this->setDateAdded(new \DateTime('now'));
- }
- /**
- * 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;
- }
- /**
- * Set authorId.
- *
- * @param int $authorId
- *
- * @return Article
- */
- public function setAuthorId($authorId)
- {
- $this->authorId = $authorId;
- return $this;
- }
- /**
- * Get authorId.
- *
- * @return int
- */
- public function getAuthorId()
- {
- return $this->authorId;
- }
- /**
- * @return User
- */
- public function getAuthor(): User
- {
- return $this->author;
- }
- /**
- * @param User $author
- */
- public function setAuthor(User $author): void
- {
- $this->author = $author;
- }
- /**
- * @return string
- */
- public function getSummary()
- {
- $summary = substr($this->getContent(), 0, strlen($this->getContent()) / 2) . "...";
- return $summary;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement