Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes, it's possible with two steps:</p> <p>1 - Override the <code>doctrine.orm.entity_manager.class</code> parameter to point to your custom entity manager (which should extend <code>Doctrine\ORM\EntityManager</code>.)</p> <p>2 - Your custom entity manager must override the <code>create</code> method so that it returns an instance of your class. See my example below, and note the last line regarding <code>MyEntityManager</code>:</p> <pre><code>public static function create($conn, Configuration $config, EventManager $eventManager = null) { if (!$config-&gt;getMetadataDriverImpl()) { throw ORMException::missingMappingDriverImpl(); } if (is_array($conn)) { $conn = \Doctrine\DBAL\DriverManager::getConnection($conn, $config, ($eventManager ? : new EventManager())); } else if ($conn instanceof Connection) { if ($eventManager !== null &amp;&amp; $conn-&gt;getEventManager() !== $eventManager) { throw ORMException::mismatchedEventManager(); } } else { throw new \InvalidArgumentException("Invalid argument: " . $conn); } // This is where you return an instance of your custom class! return new MyEntityManager($conn, $config, $conn-&gt;getEventManager()); } </code></pre> <p>You'll also need to <code>use</code> the following in your class:</p> <pre><code>use Doctrine\ORM\EntityManager; use Doctrine\ORM\Configuration; use Doctrine\ORM\ORMException; use Doctrine\Common\EventManager; use Doctrine\DBAL\Connection; </code></pre> <p>To be honest, I'm surprised that the 2nd step is required at all, I would think this should be possible to accomplish using only the service container. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload