Skip to content

Instantly share code, notes, and snippets.

@doctrinebot
Created December 13, 2015 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doctrinebot/73ee018a6104b0106503 to your computer and use it in GitHub Desktop.
Save doctrinebot/73ee018a6104b0106503 to your computer and use it in GitHub Desktop.
Attachments to Doctrine Jira Issue DDC-1034 - https://github.com/doctrine/doctrine2/issues/1623
<?php
namespace Che\Tmp;
/**
* @Entity
* @HasLifecycleCallbacks
* @InheritanceType("JOINED")
* @DiscriminatorColumn(name="discr", type="string")
* @DiscriminatorMap({
* "derived" = "Che\Tmp\DerivedClass"
* })
*/
abstract class BaseClass
{
/**
* @Id
* @Column(type="integer", name="id")
* @GeneratedValue
*/
protected $id;
protected $list;
/**
* @PostLoad
*/
public function PostLoadBase()
{
echo 'Called '.__METHOD__."\n";
$this->list = new \Doctrine\Common\Collections\ArrayCollection();
$this->list[] = 'base value';
}
}
/**
* @Entity
* @HasLifecycleCallbacks
*/
class DerivedClass extends BaseClass
{
/**
* @PostLoad
*/
public function PostLoadDerived()
{
echo 'Called '.__METHOD__."\n";
$this->list[] = 'derived value';
}
public function EchoList()
{
echo '(';
echo implode(', ', $this->list->toArray());
echo ')';
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment