<p dir="auto">Eventlisteners for doctrine LifecycleEvents are not registered on the default event manager that is available as service in the controller.</p>
<p dir="auto">Reproduce:</p>
<ol dir="auto">
<li>write an event listener</li>
</ol>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="class L{
    protected $os;
    public function __construct(MyOtherService $os){
      $this-&gt;os = $os;
    }
    public function postPersist(LifecycleEventArgs $args){
        $this-&gt;isFatal();
    }
}"><pre class="notranslate"><span class="pl-k">class</span> <span class="pl-v">L</span>{
    <span class="pl-k">protected</span> <span class="pl-c1"><span class="pl-c1">$</span>os</span>;
    <span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">__construct</span>(<span class="pl-smi"><span class="pl-smi">MyOtherService</span></span> <span class="pl-s1"><span class="pl-c1">$</span>os</span>){
      <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-c1">os</span> = <span class="pl-s1"><span class="pl-c1">$</span>os</span>;
    }
    <span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">postPersist</span>(<span class="pl-smi"><span class="pl-smi">LifecycleEventArgs</span></span> <span class="pl-s1"><span class="pl-c1">$</span>args</span>){
        <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-en">isFatal</span>();
    }
}</pre></div>
<ol start="2" dir="auto">
<li>register as service</li>
</ol>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="service:
  my_listener:
    class: \yadda\yadda\L
    arguments:
      - @my.other.service
    tags:
      - { name: doctrine.event_listener, event: postPersist }"><pre class="notranslate"><span class="pl-ent">service</span>:
  <span class="pl-ent">my_listener</span>:
    <span class="pl-ent">class</span>: <span class="pl-s">\yadda\yadda\L</span>
    <span class="pl-ent">arguments</span>:
      <span class="pl-s">- @my.other.service</span>
    <span class="pl-ent">tags</span>:
      - <span class="pl-s">{ name: doctrine.event_listener, event: postPersist }</span></pre></div>
<p dir="auto">Debuging in the controller shows no listeners are attached to the event manager on the ntity manager.</p>
<p dir="auto">I have 3 Entity classes, 2 of them are almost identical and have a foreign key constraint to the third class, in one of the classes it is possible to create the schema in the other it isn't though the constraints are the same.</p>
<p dir="auto">Referenced entity class:<br>
<a href="https://github.com/ipv6Watch/ipv6watch/blob/master/webfrontend/src/HSP/PageBundle/Entity/IPV6Router.php">https://github.com/ipv6Watch/ipv6watch/blob/master/webfrontend/src/HSP/PageBundle/Entity/IPV6Router.php</a></p>
<p dir="auto">Working entity class:<br>
<a href="https://github.com/ipv6Watch/ipv6watch/blob/master/webfrontend/src/HSP/PageBundle/Entity/IPV6v4Address.php">https://github.com/ipv6Watch/ipv6watch/blob/master/webfrontend/src/HSP/PageBundle/Entity/IPV6v4Address.php</a></p>
<p dir="auto">Defective entity class:<br>
<a href="https://github.com/ipv6Watch/ipv6watch/blob/master/webfrontend/src/HSP/PageBundle/Entity/IPV6v6Address.php">https://github.com/ipv6Watch/ipv6watch/blob/master/webfrontend/src/HSP/PageBundle/Entity/IPV6v6Address.php</a></p>
<p dir="auto">The problematic field is $RouterId.</p>