Last active
December 10, 2015 21:08
-
-
Save zluiten/4492393 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 | |
namespace Application\Entity; | |
use Doctrine\Common\Collections\ArrayCollection; | |
use Doctrine\Common\Collections\Collection; | |
use Doctrine\ORM\Mapping as ORM; | |
/** | |
* @ORM\Entity | |
*/ | |
class BlogPost | |
{ | |
/** | |
* @ORM\Id | |
* @ORM\Column(type="integer") | |
* @ORM\GeneratedValue(strategy="AUTO") | |
*/ | |
protected $id; | |
/** | |
* @ORM\OneToMany(targetEntity="Application\Entity\Tag", mappedBy="blogPost") | |
*/ | |
protected $tags; | |
/** | |
* Never forget to initialize all your collections ! | |
*/ | |
public function __construct() | |
{ | |
$this->tags = new ArrayCollection(); | |
} | |
public function getId() | |
{ | |
return $this->id; | |
} | |
public function addTag(Tag $tag) | |
{ | |
$this->tags->add($tag); | |
} | |
public function getTags() | |
{ | |
return $this->tags; | |
} | |
} | |
namespace Application\Entity; | |
use Doctrine\ORM\Mapping as ORM; | |
/** | |
* @ORM\Entity | |
*/ | |
class Tag | |
{ | |
/** | |
* @ORM\Id | |
* @ORM\Column(type="integer") | |
* @ORM\GeneratedValue(strategy="AUTO") | |
*/ | |
protected $id; | |
/** | |
* @ORM\ManyToOne(targetEntity="Application\Entity\BlogPost", inversedBy="tags") | |
*/ | |
protected $blogPost; | |
/** | |
* @ORM\Content(type="string") | |
*/ | |
protected $name; | |
public function getId() | |
{ | |
return $this->id; | |
} | |
public function setBlogPost(BlogPost $blogPos) | |
{ | |
$this->blogPost = $blogPost; | |
} | |
public function getBlogPost() | |
{ | |
return $this->blogPost; | |
} | |
public function setName($name) | |
{ | |
$this->name = $name; | |
} | |
public function getName() | |
{ | |
return $this->name; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment