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


PHP Di::get方法代碼示例

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


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

示例1: createCollection

 /**
  * @param SourceNameInterface $sourceNameData
  *
  * @return CollectionInterface
  */
 public function createCollection(SourceNameInterface $sourceNameData)
 {
     if (!is_null($sourceNameData->getUsername()) || $sourceNameData->getSource() === SourceNameInterface::SOURCE_USER) {
         return $this->di->get('Frontend\\Service\\Instagram\\Images\\UserCollectionService', array('nameData' => $sourceNameData));
     }
     return $this->di->get('Frontend\\Service\\Instagram\\Images\\FeedCollectionService');
 }
開發者ID:spalax,項目名稱:ua-webchalange-instagram-collage,代碼行數:12,代碼來源:CollectionFactory.php

示例2: postDispatchListener

 public function postDispatchListener(\Zend\Mvc\MvcEvent $e)
 {
     $script = sprintf('var FB_APP_ID = "%s";', $this->getAppId());
     /** @var $view \Zend\View\PhpRenderer */
     $view = $this->locator->get('view');
     /** @var $headScript \Zend\View\Helper\HeadScript */
     $headScript = $view->plugin('HeadScript');
     $headScript->prependScript($script);
 }
開發者ID:widmogrod,項目名稱:zf2-facebook-module,代碼行數:9,代碼來源:Module.php

示例3: run

 /**
  * Run
  *
  * @return mixed
  */
 public function run()
 {
     $dic = new Model\DiC($this->_di);
     $dic->assemble();
     /** @var \App\Bot\Updater $updater */
     $botUpdater = $this->_di->get('BotUpdater');
     $botUpdater->checkUpdates();
     /** @var \App\Redmine\Updater $redmineUpdater */
     $redmineUpdater = $this->_di->get('RedmineUpdater');
     $redmineUpdater->checkUpdates();
 }
開發者ID:VaD1ke,項目名稱:redmine_telegram_notifier,代碼行數:16,代碼來源:App.php

示例4: get

 /**
  * Finds an entry of the container by its identifier and returns it
  *
  * @param string $name
  * @throws NotFoundException  No entry was found for this identifier
  * @return mixed
  */
 public function get($name)
 {
     $args = func_get_args();
     $arguments = isset($args[1]) ? $args[1] : [];
     if (isset($this->services[$name])) {
         return $this->services[$name];
     } elseif (isset($this->map[$name])) {
         return $this->map[$name]['shared'] ? $this->services[$name] = static::$di->get($this->map[$name]['class'], ['arguments' => $arguments]) : static::$di->newInstance($this->map[$name]['class'], ['arguments' => $arguments], false);
     } elseif (isset($this->callable[$name])) {
         return $this->callable[$name]($arguments);
     } else {
         throw new NotFoundException('Method ' . $name . '() not found');
     }
 }
開發者ID:waydelyle,項目名稱:mobicms,代碼行數:21,代碼來源:Container.php

示例5: handleBotApiUpdates

 /**
  * Handle Bot API updates
  *
  * @param array $updates Updates from Bot API
  *
  * @return void
  */
 public function handleBotApiUpdates(array $updates)
 {
     $updateId = $this->_lastUpdate->getBotUpdateId();
     foreach ($updates['result'] as $update) {
         $message = trim($this->_updateHelper->getMessageText($update));
         $updateId = $this->_updateHelper->getIncrementedUpdateId($update);
         if (!$this->_isCommandExist($this->_getCommandClassName($message))) {
             continue;
         }
         /** @var ICommand $commandModel */
         $commandModel = $this->_di->get($this->_getCommandClassName($message));
         $commandModel->execute($update);
     }
     $this->_lastUpdate->setData([Model\LastUpdate::UPDATE_COLUMN_NAME => $updateId])->saveBotUpdateId();
 }
開發者ID:VaD1ke,項目名稱:redmine_telegram_notifier,代碼行數:22,代碼來源:Handler.php

示例6: createService

 public function createService(ServiceLocatorInterface $oServiceLocator)
 {
     $oServiceLocator = $oServiceLocator->getServiceLocator();
     $oAppService = $oServiceLocator->get('AppService');
     $oDi = new Di();
     $oDi->instanceManager()->setParameters('API\\Controller\\IndexController', array('app' => $oAppService));
     return $oDi->get('API\\Controller\\IndexController');
 }
開發者ID:lstaszak,項目名稱:zf2main,代碼行數:8,代碼來源:IndexController.php

示例7: get

 public function get($class)
 {
     $class = $this->normalizeClassRequest($class);
     $preferredClass = $this->di->instanceManager()->getTypePreferences($class);
     if (is_array($preferredClass) && count($preferredClass) > 0) {
         $class = array_shift($preferredClass);
     }
     return $this->di->get($class);
 }
開發者ID:kschroeder,項目名稱:Magium,代碼行數:9,代碼來源:AbstractTestCase.php

示例8: indexAction

 public function indexAction()
 {
     $config = $this->getServiceLocator('Configuration')->get('Configuration');
     $di = new Di(null, null, new Config($config['Di']));
     $basemodel = $di->get('NedVisol\\Orm\\BaseModel');
     $ret = $basemodel->adapter->putRow('test', array('id' => 'row2', 'columns' => array('cf1.a' => '234', 'cf1.b' => '456'), 'checks' => array('cf1.a' => '999')));
     echo "****{$ret}***";
     return new ViewModel();
 }
開發者ID:nedvisol,項目名稱:phporm,代碼行數:9,代碼來源:IndexController.php

示例9: __invoke

 public function __invoke(array $config = array())
 {
     $di = new Di();
     $diConfig = array('definition' => array('class' => array('Zend\\Cache\\Storage\\Adapter' => array('instantiator' => array('Eva\\Cache\\StorageFactory', 'factory')), 'Eva\\Cache\\StorageFactory' => array('methods' => array('factory' => array('cfg' => array('required' => true, 'type' => false)))))), 'instance' => array('Eva\\Cache\\StorageFactory' => array('parameters' => array('cfg' => array('adapter' => array('name' => 'filesystem', 'options' => array('cacheDir' => EVA_ROOT_PATH . '/data/cache/model/')), 'plugins' => array('serializer'))))));
     $globalConfig = $this->serviceLocator->get('Configuration');
     $globalConfig = isset($globalConfig['cache']['model']) ? $globalConfig['cache']['model'] : array();
     $diConfig = Config::mergeArray($diConfig, $globalConfig, $config);
     $di->configure(new DiConfig($diConfig));
     return $di->get('Eva\\Cache\\StorageFactory');
 }
開發者ID:ahyswang,項目名稱:eva-engine,代碼行數:10,代碼來源:ModelCache.php

示例10: __construct

 protected function __construct(Di $oDi)
 {
     $this->oJobQueueDb = $oDi->get('Classes\\Db\\JobQueue');
     $this->oBoxDb = $oDi->get('Classes\\Db\\Box');
     $this->oFolioDb = $oDi->get('Classes\\Db\\Folio');
     $this->oItemDb = $oDi->get('Classes\\Db\\Item');
     $this->oErrorLogDb = $oDi->get('Classes\\Db\\ErrorLog');
     $this->oFile = $oDi->get('Classes\\Helpers\\File');
     $this->oLogger = $oDi->get('Classes\\Helpers\\Logger');
 }
開發者ID:tomcbe,項目名稱:cbp-transcription-desk,代碼行數:10,代碼來源:TaskAbstract.php

示例11: doProxy

 /**
  * @param Di $locator
  * @return mixed
  */
 public function doProxy(Di $locator)
 {
     $options = $this->getOptions();
     $result = null;
     if ('get' === $options['method']) {
         $result = $locator->get($options['name'], $options['params']);
     } elseif ('newInstance' === $options['method']) {
         $result = $locator->newInstance($options['name'], $options['params'], $options['isShared']);
     } else {
         throw new InvalidArgumentException("'{$options['method']}' is undefined method'");
     }
     return $result;
 }
開發者ID:canaydogan,項目名稱:ukala,代碼行數:17,代碼來源:StandardProxy.php

示例12: get

 /**
  * Override, as we want it to use the functionality defined in the proxy
  *
  * @param string $name
  * @param array $params
  * @return object
  * @throws Exception\InvalidServiceNameException
  */
 public function get($name, array $params = array())
 {
     // allow this di service to get dependencies from the service locator BEFORE trying di
     if ($this->useServiceLocator == self::USE_SL_BEFORE_DI && $this->serviceLocator->has($name)) {
         return $this->serviceLocator->get($name);
     }
     try {
         $service = parent::get($name, $params);
         return $service;
     } catch (DiClassNotFoundException $e) {
         // allow this di service to get dependencies from the service locator AFTER trying di
         if ($this->useServiceLocator == self::USE_SL_AFTER_DI && $this->serviceLocator->has($name)) {
             return $this->serviceLocator->get($name);
         } else {
             throw new Exception\ServiceNotFoundException(sprintf('Service %s was not found in this DI instance', $name), null, $e);
         }
     }
 }
開發者ID:navassouza,項目名稱:zf2,代碼行數:26,代碼來源:DiServiceFactory.php

示例13: factory

 public static function factory(array $config = array())
 {
     $defaultConfig = array('di' => array('definition' => array(), 'instance' => array('Eva\\File\\Transfer\\Adapter\\Http' => array('parameters' => array()), 'Eva\\File\\Transfer\\Transfer' => array('parameters' => array('adapter' => 'Eva\\File\\Transfer\\Adapter\\Http')))));
     $globalConfig = Api::_()->getConfig();
     if (isset($globalConfig['file_transfer'])) {
         $config = array_merge($defaultConfig, $globalConfig['file_transfer'], $config);
     } else {
         $config = array_merge($defaultConfig, $config);
     }
     $diConfig = array();
     if ($config['di']) {
         $diConfig = $config['di'];
     }
     $di = new Di();
     $di->configure(new DiConfig($diConfig));
     $fileTransfer = $di->get('Eva\\File\\Transfer\\Transfer');
     //p($fileTransfer, 1);
     //@\Zend\Di\Display\Console::export($di);
     return $fileTransfer;
 }
開發者ID:ahyswang,項目名稱:eva-engine,代碼行數:20,代碼來源:TransferFactory.php

示例14: testMarkingClassAsNotSharedInjectsNewInstanceIntoAllRequestersButDependentsAreShared

 /**
  * @group SharedInstance
  */
 public function testMarkingClassAsNotSharedInjectsNewInstanceIntoAllRequestersButDependentsAreShared()
 {
     $di = new Di();
     $di->configure(new Configuration(array('instance' => array('ZendTest\\Di\\TestAsset\\SharedInstance\\Lister' => array('shared' => false)))));
     $movie = $di->get('ZendTest\\Di\\TestAsset\\SharedInstance\\Movie');
     $venue = $di->get('ZendTest\\Di\\TestAsset\\SharedInstance\\Venue');
     $this->assertNotSame($movie->lister, $venue->lister);
     $this->assertSame($movie->lister->sharedLister, $venue->lister->sharedLister);
 }
開發者ID:bradley-holt,項目名稱:zf2,代碼行數:12,代碼來源:DiTest.php

示例15: getAuthStorage

 public function getAuthStorage()
 {
     if ($this->authService) {
         return $this->authService->getStorage();
     }
     if ($this->authStorage) {
         return $this->authStorage;
     }
     $this->initStorage();
     $diConfig = $this->getDiConfig();
     $di = new Di();
     $di->configure(new DiConfig($diConfig));
     return $this->authStorage = $di->get($this->storageClass);
 }
開發者ID:ahyswang,項目名稱:eva-engine,代碼行數:14,代碼來源:Auth.php


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