Added the Comment entity
This commit is contained in:
198
src/GergelyPolonkai/FrontBundle/Entity/Comment.php
Normal file
198
src/GergelyPolonkai/FrontBundle/Entity/Comment.php
Normal file
@@ -0,0 +1,198 @@
|
||||
<?php
|
||||
namespace GergelyPolonkai\FrontBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="comments")
|
||||
*/
|
||||
class Comment
|
||||
{
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Post")
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private $post;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="User")
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=false)
|
||||
*/
|
||||
private $createdAt;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=150, nullable=true)
|
||||
*/
|
||||
private $subject;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", nullable=false)
|
||||
*/
|
||||
private $hidden;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text", nullable=false)
|
||||
*/
|
||||
private $content;
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set createdAt
|
||||
*
|
||||
* @param \DateTime $createdAt
|
||||
* @return Comment
|
||||
*/
|
||||
public function setCreatedAt($createdAt)
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get createdAt
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set subject
|
||||
*
|
||||
* @param string $subject
|
||||
* @return Comment
|
||||
*/
|
||||
public function setSubject($subject)
|
||||
{
|
||||
$this->subject = $subject;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get subject
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSubject()
|
||||
{
|
||||
return $this->subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hidden
|
||||
*
|
||||
* @param boolean $hidden
|
||||
* @return Comment
|
||||
*/
|
||||
public function setHidden($hidden)
|
||||
{
|
||||
$this->hidden = $hidden;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hidden
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getHidden()
|
||||
{
|
||||
return $this->hidden;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set content
|
||||
*
|
||||
* @param string $content
|
||||
* @return Comment
|
||||
*/
|
||||
public function setContent($content)
|
||||
{
|
||||
$this->content = $content;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set post
|
||||
*
|
||||
* @param GergelyPolonkai\FrontBundle\Entity\Post $post
|
||||
* @return Comment
|
||||
*/
|
||||
public function setPost(\GergelyPolonkai\FrontBundle\Entity\Post $post)
|
||||
{
|
||||
$this->post = $post;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get post
|
||||
*
|
||||
* @return GergelyPolonkai\FrontBundle\Entity\Post
|
||||
*/
|
||||
public function getPost()
|
||||
{
|
||||
return $this->post;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set user
|
||||
*
|
||||
* @param GergelyPolonkai\FrontBundle\Entity\User $user
|
||||
* @return Comment
|
||||
*/
|
||||
public function setUser(\GergelyPolonkai\FrontBundle\Entity\User $user = null)
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user
|
||||
*
|
||||
* @return GergelyPolonkai\FrontBundle\Entity\User
|
||||
*/
|
||||
public function getUser()
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
}
|
@@ -6,6 +6,11 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
use Gedmo\Mapping\Annotation as GedmoORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
use GergelyPolonkai\FrontBundle\Entity\Comment;
|
||||
use GergelyPolonkai\FrontBundle\Entity\User;
|
||||
|
||||
/**
|
||||
* Description of Post
|
||||
*
|
||||
@@ -73,6 +78,22 @@ class Post
|
||||
*/
|
||||
private $draft;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Doctrine\Common\Collections\ArrayCollection $comments
|
||||
*
|
||||
* @ORM\OneToMany(targetEntity="Comment", mappedBy="post", fetch="LAZY")
|
||||
*/
|
||||
private $comments;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->comments = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
@@ -122,7 +143,7 @@ class Post
|
||||
* @param GergelyPolonkai\FrontBundle\Entity\User $user
|
||||
* @return Post
|
||||
*/
|
||||
public function setUser(\GergelyPolonkai\FrontBundle\Entity\User $user)
|
||||
public function setUser(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
@@ -191,7 +212,7 @@ class Post
|
||||
* @param \DateTime $createdAt
|
||||
* @return Post
|
||||
*/
|
||||
public function setCreatedAt($createdAt)
|
||||
public function setCreatedAt(\DateTime $createdAt)
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
|
||||
@@ -220,4 +241,36 @@ class Post
|
||||
{
|
||||
return $this->draft;
|
||||
}
|
||||
/**
|
||||
* Add comments
|
||||
*
|
||||
* @param GergelyPolonkai\FrontBundle\Entity\Comment $comments
|
||||
* @return Post
|
||||
*/
|
||||
public function addComment(Comment $comments)
|
||||
{
|
||||
$this->comments[] = $comments;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove comments
|
||||
*
|
||||
* @param GergelyPolonkai\FrontBundle\Entity\Comment $comments
|
||||
*/
|
||||
public function removeComment(Comment $comments)
|
||||
{
|
||||
$this->comments->removeElement($comments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get comments
|
||||
*
|
||||
* @return Doctrine\Common\Collections\Collection
|
||||
*/
|
||||
public function getComments()
|
||||
{
|
||||
return $this->comments;
|
||||
}
|
||||
}
|
||||
|
@@ -7,4 +7,4 @@
|
||||
</ul>
|
||||
{% block admincontent %}
|
||||
{% endblock %}
|
||||
{% endblock content %}
|
||||
{% endblock content %}
|
||||
|
@@ -30,4 +30,4 @@
|
||||
{% include 'GergelyPolonkaiFrontBundle:Blog:postViewer.html.twig' with {'post': post, 'title_links': true} %}
|
||||
{% endfor %}
|
||||
{{ block('paginator') }}
|
||||
{% endblock content %}
|
||||
{% endblock content %}
|
||||
|
@@ -7,4 +7,4 @@
|
||||
<p>I'm learning about different IT subjects since the late '90s. These include web development, application building, systems engineering, systems security and many others. I also dug my nose into free software, dealing with different types of Linux and its applications, while also writing and contributing to some open source projects.</p>
|
||||
<p>On this site I will write blog posts about different stuff I face during work (oh my, yet another IT solutions blog), hoping they can help you with your own, or just to get along with your brand new netbook that shipped with Linux.</p>
|
||||
<p>Feel free to send me any suggestions on what should I post. I will try my best to provide some help or directions.</p>
|
||||
{% endblock content %}
|
||||
{% endblock content %}
|
||||
|
@@ -2,7 +2,6 @@
|
||||
namespace GergelyPolonkai\FrontBundle\Twig;
|
||||
|
||||
use JMS\DiExtraBundle\Annotation as DI;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Description of RandomHeader
|
||||
@@ -45,10 +44,12 @@ class RandomHeader extends \Twig_Extension
|
||||
$files[] = $fn;
|
||||
}
|
||||
}
|
||||
|
||||
return $files[array_rand($files)];
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
public function getName()
|
||||
{
|
||||
return 'random_header';
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user