Last active
August 23, 2017 03:10
-
-
Save cod1ingcoding/e307c107f6035ebfbcbf33c2641f2847 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Epost.php | |
use Doctrine\Common\Collections\ArrayCollection; | |
/** | |
* @Entity @Table(name="e_post", options={"collate"="utf8_general_ci"}) | |
*/ | |
class Epost | |
{ | |
/** | |
* @Id @GeneratedValue @Column(type="integer") | |
* @var int | |
*/ | |
protected $id; | |
public function getId() { return $this->id; } | |
public function __construct() | |
{ | |
$this->etags = new ArrayCollection(); | |
} | |
/** | |
* @var Etags[]|ArrayCollection | |
* @ManyToMany(targetEntity="Etag") | |
* JoinTable( | |
* name="e_posts_tags", | |
* joinColumns={@JoinColumn(name="epost_id", referencedColumnName="id")}, | |
* inversedJoinColumns={@JoinColumn(name="etag_id", referencedColumnName="id")} | |
* ) | |
*/ | |
protected $etags; | |
public function getEtags() { return $this->etags; } | |
/** | |
* @var string | |
* @Column(type="string", name="post_title", length=128) | |
*/ | |
protected $title; | |
public function getTitle() { return $this->title; } | |
public function setTitle($title) { $this->title = $title; return $this; } | |
/** | |
* @var string | |
* @Column(type="text", name="post_content") | |
*/ | |
protected $content; | |
public function getContent() { return $this->content; } | |
public function setContent($content) { $this->content = $content; return $this; } | |
public function addEtag(Etag $etag) | |
{ | |
if ($this->etags->contains($etag)) return; | |
$this->etags->add($etag); | |
} | |
public function removeEtag(Etag $etag) | |
{ | |
if (!$this->etags->contains($etag)) return; | |
$this->etags->removeElement($etag); | |
} | |
} | |
//Etag.php | |
/** | |
* @Entity @Table(name="e_tags", options={"collate"="utf8_general_ci"}) | |
*/ | |
class Etag | |
{ | |
/** | |
* @Id @GeneratedValue @Column(type="integer") | |
* @var int | |
*/ | |
protected $id; | |
public function getId() { return $this->id; } | |
/** | |
* @var string | |
* @Column(type="string", name="tag_name", length=128) | |
*/ | |
protected $name; | |
public function getName() { return $this->name; } | |
public function setName($name) { $this->name = $name; return $this; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment