SHARE
TWEET

Article

a guest Dec 24th, 2017 131 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. namespace SoftUniBlogBundle\Entity;
  4.  
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\ORM\Mapping as ORM;
  7.  
  8. /**
  9.  * Article
  10.  *
  11.  * @ORM\Table(name="articles")
  12.  * @ORM\Entity(repositoryClass="SoftUniBlogBundle\Repository\ArticleRepository")
  13.  */
  14. class Article
  15. {
  16.     /**
  17.      * @var int
  18.      *
  19.      * @ORM\Column(name="id", type="integer")
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue(strategy="AUTO")
  22.      */
  23.     private $id;
  24.  
  25.     /**
  26.      * @var string
  27.      *
  28.      * @ORM\Column(name="title", type="string", length=255)
  29.      */
  30.     private $title;
  31.  
  32.     /**
  33.      * @var string
  34.      *
  35.      * @ORM\Column(name="content", type="text")
  36.      */
  37.     private $content;
  38.  
  39.     /**
  40.      * @var \DateTime
  41.      *
  42.      * @ORM\Column(name="dateAdded", type="datetime")
  43.      */
  44.     private $dateAdded;
  45.  
  46.     /**
  47.      * @var string
  48.      */
  49.     private $summary;
  50.  
  51.     /**
  52.      * @param string
  53.      */
  54.     private function setSummary()
  55.     {
  56.         $this->summary = substr($this->getContent(), 0, strlen($this->getContent()) / 2) . "...";
  57.     }
  58.  
  59.     /**
  60.      * @return string
  61.      */
  62.     private  function getSummary()
  63.     {
  64.         if ($this->summary === null)
  65.         {
  66.             $this->setSummary();
  67.         }
  68.         return $this->summary;
  69.     }
  70.  
  71.     /**
  72.      * @var int
  73.      *
  74.      * @ORM\Column(name="authorID", type="integer")
  75.      */
  76.     private $authorID;
  77.  
  78.     /**
  79.      * @param integer $authorID
  80.      *
  81.      * @return Article
  82.      */
  83.     private function setAuthorID($authorID)
  84.     {
  85.         $this->authorID = $authorID;
  86.  
  87.         return $this;
  88.     }
  89.  
  90.     /**
  91.      * @return int
  92.      */
  93.     public function getAuthorID()
  94.     {
  95.         return $this->authorID;
  96.     }
  97.  
  98.     /**
  99.      * @var User
  100.      *
  101.      * @ORM\ManyToOne(targetEntity="SoftUniBlogBundle\Entity\User", inversedBy="articles")
  102.      * @ORM\JoinColumn(name="authorID", referencedColumnName="id")
  103.      */
  104.     private $author;
  105.  
  106.     /**
  107.      * @param \SoftUniBlogBundle\Entity\User $author
  108.      *
  109.      * @return Article
  110.      */
  111.     public function setAuthor(User $author = null)
  112.     {
  113.         $this->author = $author;
  114.  
  115.         return $this;
  116.     }
  117.  
  118.     /**
  119.      * @return \SoftUniBlogBundle\Entity\User
  120.      */
  121.     public function getAuthor()
  122.     {
  123.         return $this->author;
  124.     }
  125.  
  126.     /**
  127.      * Get id
  128.      *
  129.      * @return int
  130.      */
  131.     public function getId()
  132.     {
  133.         return $this->id;
  134.     }
  135.  
  136.     /**
  137.      * Set title
  138.      *
  139.      * @param string $title
  140.      *
  141.      * @return Article
  142.      */
  143.     public function setTitle($title)
  144.     {
  145.         $this->title = $title;
  146.  
  147.         return $this;
  148.     }
  149.  
  150.     /**
  151.      * Get title
  152.      *
  153.      * @return string
  154.      */
  155.     public function getTitle()
  156.     {
  157.         return $this->title;
  158.     }
  159.  
  160.     /**
  161.      * Set content
  162.      *
  163.      * @param string $content
  164.      *
  165.      * @return Article
  166.      */
  167.     public function setContent($content)
  168.     {
  169.         $this->content = $content;
  170.  
  171.         return $this;
  172.     }
  173.  
  174.     /**
  175.      * Get content
  176.      *
  177.      * @return string
  178.      */
  179.     public function getContent()
  180.     {
  181.         return $this->content;
  182.     }
  183.  
  184.     /**
  185.      * Set dateAdded
  186.      *
  187.      * @param \DateTime $dateAdded
  188.      *
  189.      * @return Article
  190.      */
  191.     public function setDateAdded($dateAdded)
  192.     {
  193.         $this->dateAdded = $dateAdded;
  194.  
  195.         return $this;
  196.     }
  197.  
  198.     /**
  199.      * Get dateAdded
  200.      *
  201.      * @return \DateTime
  202.      */
  203.     public function getDateAdded()
  204.     {
  205.         return $this->dateAdded;
  206.     }
  207.  
  208.     public function __construct()
  209.     {
  210.         $this->dateAdded = new \DateTime('now');
  211.     }
  212. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top