/**
  * Create EntityManager
  * 
  * @param Connection $connection
  * @return \Doctrine\ORM\EntityManager
  */
 public function create(Connection $connection)
 {
     // Get config with containing all metadata drivers
     $configuration = $this->configFactory->getConfiguration();
     // Get orm event manager
     $eventManager = $connection->getEventManager();
     // Pass the database connection, the orm config and the event manager
     // to the concrete5 event system so packages can hook in to the process
     // and alter the values
     $event = new \Symfony\Component\EventDispatcher\GenericEvent();
     $event->setArgument('connection', $connection);
     $event->setArgument('configuration', $configuration);
     $event->setArgument('eventManager', $eventManager);
     Events::dispatch('on_entity_manager_configure', $event);
     // Reasign the values from the dispatched event
     $conn = $event->getArgument('connection');
     $config = $event->getArgument('configuration');
     $evm = $event->getArgument('eventManager');
     // Inject the orm eventManager into the entityManager so orm events
     // can be triggered.
     return EntityManager::create($conn, $config, $evm);
 }