|
<?php |
|
|
|
namespace UP\SocialBundle\Entity; |
|
|
|
/** |
|
* UP\SocialBundle\Entity\SocialBase |
|
* @orm:Entity |
|
* @orm:HasLifecycleCallbacks |
|
* @orm:InheritanceType("JOINED") |
|
* @orm:DiscriminatorColumn(name="class_name", type="string") |
|
* @orm:DiscriminatorMap({ |
|
* "UP\SocialBundle\Entity\Friendship" = "UP\SocialBundle\Entity\Friendship", |
|
* "UP\SocialBundle\Entity\SocialFeedItem" = "UP\SocialBundle\Entity\SocialFeedItem" |
|
* }) |
|
*/ |
|
abstract class SocialBase { |
|
/** |
|
* @orm:Id |
|
* @orm:Column(type="integer") |
|
* @orm:GeneratedValue |
|
*/ |
|
protected $id; |
|
|
|
/** |
|
* @orm:Column(type="datetime") |
|
*/ |
|
protected $created_at; |
|
|
|
/** |
|
* @orm:Column(type="datetime") |
|
*/ |
|
protected $updated_at; |
|
|
|
/** |
|
* @orm:ManyToMany(targetEntity="UP\SocialBundle\Entity\Tag") |
|
* @orm:JoinTable(name="social_tags", |
|
* joinColumns={@orm:JoinColumn(name="social_id", referencedColumnName="id")}, |
|
* inverseJoinColumns={@orm:JoinColumn(name="tag_id", referencedColumnName="id")} |
|
* ) |
|
*/ |
|
protected $tags; |
|
|
|
/** |
|
* @orm:OneToMany(targetEntity="UP\SocialBundle\Entity\Comment", mappedBy="root") |
|
*/ |
|
protected $comments; |
|
|
|
public function __construct() |
|
{ |
|
$this->tags = new \Doctrine\Common\Collections\ArrayCollection(); |
|
} |
|
|
|
public function getId() |
|
{ |
|
return $this->id; |
|
} |
|
|
|
public function addTag(\UP\SocialBundle\Entity\Tag $tag) |
|
{ |
|
$this->tags[] = $tag; |
|
} |
|
|
|
public function getTags() |
|
{ |
|
return $this->tags; |
|
} |
|
|
|
public function addComment(\UP\SocialBundle\Entity\Comment $comment) |
|
{ |
|
$this->comments[] = $comment; |
|
} |
|
|
|
public function getComments() |
|
{ |
|
return $this->comments; |
|
} |
|
|
|
public function setCreatedAt(\DateTime $created_at) { |
|
$this->created_at = $created_at; |
|
} |
|
|
|
public function getCreatedAt() { |
|
return $this->created_at; |
|
} |
|
|
|
public function setUpdatedAt(\DateTime $updated_at) { |
|
$this->updated_at = $updated_at; |
|
} |
|
|
|
public function getUpdatedAt() { |
|
return $this->updated_at; |
|
} |
|
|
|
/** |
|
* @orm:prePersist |
|
*/ |
|
public function prePersist() { |
|
$this->setCreatedAt(new \DateTime()); |
|
$this->setUpdatedAt(new \DateTime()); |
|
} |
|
|
|
/** |
|
* @orm:preUpdate |
|
*/ |
|
public function preUpdate() { |
|
$this->setUpdatedAt(new \DateTime()); |
|
} |
|
} |
+1