-
-
Save doctrinebot/479549bb5a53125657cc to your computer and use it in GitHub Desktop.
Attachments to Doctrine Jira Issue DBAL-58 - https://github.com/doctrine/dbal/issues/1790
This file contains 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 Example\Entity; | |
/** | |
* Entity Article Item. | |
* | |
* @Entity | |
* @ChangeTrackingPolicy("DEFERRED_EXPLICIT") | |
*/ | |
class ArticleItem | |
{ | |
/** | |
* ID. | |
* | |
* @var int | |
* @Id | |
* @Column(type="integer") | |
* @GeneratedValue | |
*/ | |
protected $id; | |
/** | |
* Name | |
* | |
* @var string | |
* @Column(type="string") | |
*/ | |
protected $name; | |
/** | |
* article group id. | |
* | |
* @var int | |
* @Column(type="integer") | |
*/ | |
protected $articleGroupId; | |
/** | |
* Article groups. | |
* | |
* @var \Example\Entity\ArticleGroup | |
* @ManyToOne(targetEntity="Example\Entity\ArticleGroup", inversedBy="articleItems") | |
* @JoinColumn(name="articleGroupId", referencedColumnName="id", onDelete="RESTRICT") | |
*/ | |
protected $articleGroup; | |
/** | |
* Constructor. | |
*/ | |
public function __construct() | |
{ | |
} | |
/** | |
* Returns ID. | |
* | |
* @return int | |
*/ | |
public function getId() | |
{ | |
return $this->id; | |
} | |
/** | |
* Returns name. | |
* | |
* @return string | |
*/ | |
public function getName() | |
{ | |
return $this->name; | |
} | |
/** | |
* Sets name. | |
* | |
* @param string $name | |
* @return \Example\Entity\ArticleItem | |
*/ | |
public function setName($name) | |
{ | |
$this->name = $name; | |
return $this; | |
} | |
/** | |
* Returns article group. | |
* | |
* @return \Example\Entity\ArticleGroup | |
*/ | |
public function getArticleGroup() | |
{ | |
return $this->articleGroup; | |
} | |
/** | |
* Sets article item. | |
* | |
* @param \Example\Entity\ArticleGroup $articleGroup | |
* @param bool $inverseToo | |
* @return \Example\Entity\ArticleItem | |
*/ | |
public function setArticleGroup(\Example\Entity\ArticleGroup $articleGroup, $inverseToo = true) | |
{ | |
$this->articleGroup = $articleGroup; | |
if($inverseToo == true) { | |
$articleGroup->addArticleItem($this, false); | |
} | |
return $this; | |
} | |
} | |
/** | |
* Entity Article Group. | |
* | |
* @Entity | |
* @ChangeTrackingPolicy("DEFERRED_EXPLICIT") | |
*/ | |
class ArticleGroup | |
{ | |
/** | |
* ID. | |
* | |
* @var int | |
* @Id | |
* @Column(type="integer") | |
* @GeneratedValue | |
*/ | |
protected $id; | |
/** | |
* Name | |
* | |
* @var string | |
* @Column(type="string") | |
*/ | |
protected $name; | |
/** | |
* Article items. | |
* | |
* @var \Doctrine\Common\Collections\ArrayCollection | |
* @OneToMany(targetEntity="Example\Entity\ArticleItem", mappedBy="articleGroup") | |
* @OrderBy({"name" = "ACS"}) | |
*/ | |
protected $articleItems; | |
/** | |
* Constructor. | |
*/ | |
public function __construct() | |
{ | |
$this->articleItems = new \Doctrine\Common\Collections\ArrayCollection(); | |
} | |
/** | |
* Returns id. | |
* | |
* @return int | |
*/ | |
public function getId() | |
{ | |
return $this->id; | |
} | |
/** | |
* Returns name. | |
* | |
* @return string | |
*/ | |
public function getName() | |
{ | |
return $this->name; | |
} | |
/** | |
* Sets name. | |
* | |
* @param string $name | |
* @return \Example\Entity\ArticleGroup | |
*/ | |
public function setName($name) | |
{ | |
$this->name = $name; | |
return $this; | |
} | |
/** | |
* Returns array of article items. | |
* | |
* @return \Doctrine\Common\Collections\ArrayCollection | |
*/ | |
public function getArticleItems() | |
{ | |
return $this->articleItems; | |
} | |
/** | |
* Adds article item. | |
* | |
* @param \Example\Entity\ArticleItem $articleItem | |
* @param bool $inverseToo | |
* @return \Example\Entity\ArticleGroup | |
*/ | |
public function addArticleItem(\Example\Entity\ArticleItem $articleItem, $inverseToo = true) | |
{ | |
$this->articleItems->add($articleItem); | |
if($inverseToo == true) { | |
$articleItem->setArticleGroup($this, false); | |
} | |
return $this; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment