Пример #1
0
 /**
  * Factory method to create EntityManager instances.
  *
  * @param Connection $conn
  * @param Configuration $config
  * @param EventManager $eventManager
  * @throws \Doctrine\ORM\ORMException
  * @return ModelManager
  */
 public static function createInstance(Connection $conn, Configuration $config, EventManager $eventManager = null)
 {
     if (!$config->getMetadataDriverImpl()) {
         throw ORMException::missingMappingDriverImpl();
     }
     if ($eventManager !== null && $conn->getEventManager() !== $eventManager) {
         throw ORMException::mismatchedEventManager();
     }
     return new self($conn, $config, $conn->getEventManager());
 }
Пример #2
0
 /**
  * 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;
 }
Пример #3
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;
 }
Пример #4
0
 /**
  *
  */
 public function start()
 {
     $this->modelLogger = new DebugStack();
     $this->modelConfig->setSQLLogger($this->modelLogger);
 }