/**
  * Creates the entity manager for the application.
  *
  * @param Configuration $config
  * @param string        $modelPath
  * @return AnnotationDriver
  */
 public function factory(Configuration $config, $modelPath)
 {
     $annotationDriver = new AnnotationDriver($config->getAnnotationsReader(), array($modelPath, $config->getAttributeDir()));
     // create a driver chain for metadata reading
     $driverChain = new MappingDriverChain();
     // register annotation driver for our application
     $driverChain->addDriver($annotationDriver, 'Shopware\\Models\\');
     $driverChain->addDriver($annotationDriver, 'Shopware\\CustomModels\\');
     $config->setMetadataDriverImpl($driverChain);
     return $annotationDriver;
 }
Example #2
0
 /**
  * Creates the entity manager for the application.
  *
  * @param EventManager      $eventManager
  * @param Configuration     $config
  * @param \Enlight_Loader   $loader
  * @param \Pdo              $db
  * @param string            $kernelRootDir
  * @param AnnotationDriver  $modelAnnotation
  *
  * @return ModelManager
  */
 public function factory(EventManager $eventManager, Configuration $config, \Enlight_Loader $loader, \PDO $db, $kernelRootDir, AnnotationDriver $modelAnnotation)
 {
     $vendorPath = $kernelRootDir . '/vendor';
     // register standard doctrine annotations
     AnnotationRegistry::registerFile($vendorPath . '/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');
     // register symfony validation annotations
     AnnotationRegistry::registerAutoloadNamespace('Symfony\\Component\\Validator\\Constraint', realpath($vendorPath . '/symfony/validator'));
     $loader->registerNamespace('Shopware\\Models\\Attribute', $config->getAttributeDir());
     // now create the entity manager and use the connection
     // settings we defined in our application.ini
     $conn = DriverManager::getConnection(array('pdo' => $db), $config, $eventManager);
     $conn->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
     $conn->getDatabasePlatform()->registerDoctrineTypeMapping('bit', 'boolean');
     $entityManager = ModelManager::createInstance($conn, $config, $eventManager);
     LazyFetchModelEntity::setEntityManager($entityManager);
     return $entityManager;
 }