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


PHP Helpers::createObject方法代碼示例

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


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

示例1: processConnection

 protected function processConnection($name, array $defaults, $isDefault = FALSE)
 {
     $builder = $this->getContainerBuilder();
     $config = $this->resolveConfig($defaults, $this->connectionDefaults, $this->managerDefaults);
     if ($isDefault) {
         $builder->parameters[$this->name]['dbal']['defaultConnection'] = $name;
     }
     if (isset($defaults['connection'])) {
         return $this->prefix('@' . $defaults['connection'] . '.connection');
     }
     // config
     $configuration = $builder->addDefinition($this->prefix($name . '.dbalConfiguration'))->setClass('Doctrine\\DBAL\\Configuration')->addSetup('setResultCacheImpl', array($this->processCache($config['resultCache'], $name . '.dbalResult')))->addSetup('setSQLLogger', array(new Statement('Doctrine\\DBAL\\Logging\\LoggerChain')))->addSetup('setFilterSchemaAssetsExpression', array($config['schemaFilter']))->setAutowired(FALSE)->setInject(FALSE);
     // types
     Validators::assertField($config, 'types', 'array');
     $schemaTypes = $dbalTypes = array();
     foreach ($config['types'] as $dbType => $className) {
         $typeInst = Code\Helpers::createObject($className, array());
         /** @var Doctrine\DBAL\Types\Type $typeInst */
         $dbalTypes[$typeInst->getName()] = $className;
         $schemaTypes[$dbType] = $typeInst->getName();
     }
     // tracy panel
     if ($this->isTracyPresent()) {
         $builder->addDefinition($this->prefix($name . '.diagnosticsPanel'))->setClass('Kdyby\\Doctrine\\Diagnostics\\Panel')->setAutowired(FALSE);
     }
     // connection
     $options = array_diff_key($config, array_flip(array('types', 'resultCache', 'connection', 'logging')));
     $connection = $builder->addDefinition($connectionServiceId = $this->prefix($name . '.connection'))->setClass('Kdyby\\Doctrine\\Connection')->setFactory('Kdyby\\Doctrine\\Connection::create', array($options, $this->prefix('@' . $name . '.dbalConfiguration'), $this->prefix('@' . $name . '.evm')))->addSetup('setSchemaTypes', array($schemaTypes))->addSetup('setDbalTypes', array($dbalTypes))->addTag(self::TAG_CONNECTION)->addTag('kdyby.doctrine.connection')->setAutowired($isDefault)->setInject(FALSE);
     if ($this->isTracyPresent()) {
         $connection->addSetup('$panel = ?->bindConnection(?)', [$this->prefix('@' . $name . '.diagnosticsPanel'), '@self']);
     }
     /** @var Nette\DI\ServiceDefinition $connection */
     $this->configuredConnections[$name] = $connectionServiceId;
     if (!is_bool($config['logging'])) {
         $fileLogger = new Statement('Kdyby\\Doctrine\\Diagnostics\\FileLogger', array($builder->expand($config['logging'])));
         $configuration->addSetup('$service->getSQLLogger()->addLogger(?)', array($fileLogger));
     } elseif ($config['logging']) {
         $connection->addSetup('?->enableLogging()', array(new Code\PhpLiteral('$panel')));
     }
     return $this->prefix('@' . $name . '.connection');
 }
開發者ID:psyrny,項目名稱:Doctrine,代碼行數:41,代碼來源:OrmExtension.php


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