當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ORMException::missingMappingDriverImpl方法代碼示例

本文整理匯總了PHP中Doctrine\ORM\ORMException::missingMappingDriverImpl方法的典型用法代碼示例。如果您正苦於以下問題:PHP ORMException::missingMappingDriverImpl方法的具體用法?PHP ORMException::missingMappingDriverImpl怎麽用?PHP ORMException::missingMappingDriverImpl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\ORM\ORMException的用法示例。


在下文中一共展示了ORMException::missingMappingDriverImpl方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: create

 /**
  * {@inheritdoc}
  */
 public static function create($conn, Configuration $config, EventManager $eventManager = null)
 {
     if (!$config->getMetadataDriverImpl()) {
         throw ORMException::missingMappingDriverImpl();
     }
     switch (true) {
         case is_array($conn):
             if (!$eventManager) {
                 $eventManager = new EventManager();
             }
             if (isset($conn['prefix']) && $conn['prefix']) {
                 $eventManager->addEventListener(Events::loadClassMetadata, new TablePrefix($conn['prefix']));
             }
             $conn = \Doctrine\DBAL\DriverManager::getConnection($conn, $config, $eventManager);
             break;
         case $conn instanceof Connection:
             if ($eventManager !== null && $conn->getEventManager() !== $eventManager) {
                 throw ORMException::mismatchedEventManager();
             }
             break;
         default:
             throw new \InvalidArgumentException("Invalid argument: " . $conn);
     }
     return new self($conn, $config, $conn->getEventManager());
 }
開發者ID:minchal,項目名稱:vero,代碼行數:28,代碼來源:EntityManager.php

示例2: __construct

 /**
  * @param string|mixed|\ $dsn
  * @param array $options
  *
  * @return AdapterInterface
  *
  * @link http://docs.doctrine-project.org/en/2.0.x/reference/configuration.html
  * @link http://docs.doctrine-project.org/en/latest/reference/tools.html
  * @link https://github.com/itmcd/StormIgniter/blob/master/app/libraries/DoctrineDb.php
  * @link http://framework.zend.com/manual/2.2/en/user-guide/database-and-models.html
  * @link http://piotrdeszynski.com/zend-framework-2-and-doctrine-2-integration.html
  * @link http://www.jasongrimes.org/2012/01/using-doctrine-2-in-zend-framework-2/#toc-update-the-album-controller-to-use-doctrine-instead-of-zend_db
  * @link http://framework.zend.com/manual/2.2/en/user-guide/database-and-models.html
  */
 public function __construct($conn, $options = array())
 {
     $isDev = Environment::isDev();
     // @see Doctrine\ORM\EntityManager#create()
     $config = ArrayUtils::arrayMergeRecursiveRight($options, array('cache' => $isDev ? new Cache\ArrayCache() : new Cache\ApcCache(), 'queryCache' => $isDev ? new Cache\ArrayCache() : new Cache\ApcCache(), 'modelsProxiesPath' => getcwd() . '/cache/ModelProxies'));
     // create Configuration object
     if (is_array($options)) {
         $config = $this->renderConfig($options);
         if (!$config->getMetadataDriverImpl()) {
             throw ORMException::missingMappingDriverImpl();
         }
     }
     // test EventManager object
     $eventManager = empty($options['eventManager']) ? new EventManager() : $options['eventManager'];
     switch (true) {
         case $conn instanceof \PDO:
             $conn = array('driver' => 'pdo_' . $conn->getAttribute(\PDO::ATTR_DRIVER_NAME), 'pdo' => $conn);
             $conn = \Doctrine\DBAL\DriverManager::getConnection($conn, $config, $eventManager);
             break;
         case is_string($conn):
             if (($pos = strpos($conn, ':')) !== false) {
                 $driver = substr($conn, 0, $pos);
                 //                    @TODO: must implement like this, but for now throws an error about not knowing the database
                 //                    if ($driver !== 'oci8') {
                 //                        $conn = array(
                 //                            'driver' => 'pdo_' . $driver,
                 //                            'pdo' => new \PDO($conn),
                 //                        );
                 //                    } else {
                 //                        $conn = $this->mapDsnToDoctrine($conn);
                 //                    }
                 //                    ^ by dragosc@itmcd.ro / temporary replacement untill we discover why \PDO doesn't work
                 $dsn = new Dsn($conn);
                 $conn = $this->mapDsnToDoctrine($dsn->parse());
                 if ($driver !== 'oci8') {
                     $conn['driver'] = 'pdo_' . $conn['driver'];
                 }
                 //                    ^ END
             }
             $conn = \Doctrine\DBAL\DriverManager::getConnection($conn, $config, $eventManager);
             break;
         case is_array($conn):
             $conn = \Doctrine\DBAL\DriverManager::getConnection($conn, $config, $eventManager);
             break;
         case $conn instanceof Connection:
             if ($eventManager !== null && $conn->getEventManager() !== null) {
                 throw ORMException::mismatchedEventManager();
             }
             break;
         default:
             throw new AthemException\InvalidArgument("Invalid argument: " . json_encode($conn));
     }
     // parent constructor
     // @see Doctrine\ORM\EntityManager#__construct()
     parent::__construct($conn, $config, $conn->getEventManager());
 }
開發者ID:athemcms,項目名稱:netis,代碼行數:70,代碼來源:EntityManager.php

示例3: createInstance

 /**
  * 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());
 }
開發者ID:GerDner,項目名稱:luck-docker,代碼行數:19,代碼來源:ModelManager.php

示例4: create

 public static function create($conn, Configuration $config, EventManager $eventManager = null)
 {
     if (!$config->getMetadataDriverImpl()) {
         throw ORMException::missingMappingDriverImpl();
     }
     if (is_array($conn)) {
         $conn = \Doctrine\DBAL\DriverManager::getConnection($conn, $config, $eventManager ?: new EventManager());
     } elseif ($conn instanceof Connection) {
         if ($eventManager !== null && $conn->getEventManager() !== $eventManager) {
             throw ORMException::mismatchedEventManager();
         }
     } else {
         throw new \InvalidArgumentException("Invalid argument: " . $conn);
     }
     return new OroEntityManager($conn, $config, $conn->getEventManager());
 }
開發者ID:xamin123,項目名稱:platform,代碼行數:16,代碼來源:OroEntityManager.php

示例5: create

 /**
  * Copied from Doctrine\ORM\EntityManager, cause return use new EntityManager() instead of new static()
  *
  * @param mixed $conn
  * @param Configuration $config
  * @param EventManager|null $eventManager
  * @return EntityManager
  * @throws ORMException
  * @throws \Doctrine\DBAL\DBALException
  */
 public static function create($conn, Configuration $config, EventManager $eventManager = null)
 {
     if (!$config->getMetadataDriverImpl()) {
         throw ORMException::missingMappingDriverImpl();
     }
     switch (true) {
         case is_array($conn):
             $conn = \Doctrine\DBAL\DriverManager::getConnection($conn, $config, $eventManager ?: new EventManager());
             break;
         case $conn instanceof Connection:
             if ($eventManager !== null && $conn->getEventManager() !== $eventManager) {
                 throw ORMException::mismatchedEventManager();
             }
             break;
         default:
             throw new \InvalidArgumentException("Invalid argument: " . $conn);
     }
     return new static($conn, $config, $conn->getEventManager());
 }
開發者ID:steevanb,項目名稱:doctrine-stats,代碼行數:29,代碼來源:EntityManager.php

示例6: create

 /**
  * Factory method to create EntityManager instances.
  *
  * @param \Doctrine\DBAL\Connection|array $conn
  * @param \Doctrine\ORM\Configuration $config
  * @param \Doctrine\Common\EventManager $eventManager
  * @throws \Doctrine\ORM\ORMException
  * @throws InvalidArgumentException
  * @throws \Doctrine\ORM\ORMException
  * @return EntityManager
  */
 public static function create($conn, Doctrine\ORM\Configuration $config, Doctrine\Common\EventManager $eventManager = NULL)
 {
     if (!$config->getMetadataDriverImpl()) {
         throw ORMException::missingMappingDriverImpl();
     }
     switch (TRUE) {
         case is_array($conn):
             $conn = DriverManager::getConnection($conn, $config, $eventManager ?: new Doctrine\Common\EventManager());
             break;
         case $conn instanceof Doctrine\DBAL\Connection:
             if ($eventManager !== NULL && $conn->getEventManager() !== $eventManager) {
                 throw ORMException::mismatchedEventManager();
             }
             break;
         default:
             throw new InvalidArgumentException("Invalid connection");
     }
     return new EntityManager($conn, $config, $conn->getEventManager());
 }
開發者ID:jirinapravnik,項目名稱:common,代碼行數:30,代碼來源:EntityManager.php

示例7: create

 /**
  * Factory method to create EntityManager instances.
  *
  * @param array|Connection $connection   An array with the connection parameters or an existing Connection instance.
  * @param Configuration    $config       The Configuration instance to use.
  * @param EventManager     $eventManager The EventManager instance to use.
  *
  * @return EntityManager The created EntityManager.
  *
  * @throws \InvalidArgumentException
  * @throws ORMException
  */
 public static function create($connection, Configuration $config, EventManager $eventManager = null)
 {
     if (!$config->getMetadataDriverImpl()) {
         throw ORMException::missingMappingDriverImpl();
     }
     $connection = static::createConnection($connection, $config, $eventManager);
     return new EntityManager($connection, $config, $connection->getEventManager());
 }
開發者ID:AdactiveSAS,項目名稱:doctrine2,代碼行數:20,代碼來源:EntityManager.php


注:本文中的Doctrine\ORM\ORMException::missingMappingDriverImpl方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。