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


PHP ContainerInterface::injectOn方法代碼示例

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


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

示例1: initController

 public function initController(\Zend_EventManager_Event $e)
 {
     $controller = $e->getTarget();
     $this->container->injectOn($controller);
 }
開發者ID:diePartments,項目名稱:pimcore-dependency-injection-plugin,代碼行數:5,代碼來源:Plugin.php

示例2: dispatch

 /**
  * {@inheritdoc}
  *
  * The body of this method is a copy-paste of the parent class
  */
 public function dispatch(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response)
 {
     $this->setResponse($response);
     /**
      * Get controller class
      */
     if (!$this->isDispatchable($request)) {
         $controller = $request->getControllerName();
         if (!$this->getParam('useDefaultControllerAlways') && !empty($controller)) {
             throw new Zend_Controller_Dispatcher_Exception('Invalid controller specified (' . $request->getControllerName() . ')');
         }
         $className = $this->getDefaultControllerClass($request);
     } else {
         $className = $this->getControllerClass($request);
         if (!$className) {
             $className = $this->getDefaultControllerClass($request);
         }
     }
     /**
      * If we're in a module or prefixDefaultModule is on, we must add the module name
      * prefix to the contents of $className, as getControllerClass does not do that automatically.
      * We must keep a separate variable because modules are not strictly PSR-0: We need the no-module-prefix
      * class name to do the class->file mapping, but the full class name to insantiate the controller
      */
     $moduleClassName = $className;
     if ($this->_defaultModule != $this->_curModule || $this->getParam('prefixDefaultModule')) {
         $moduleClassName = $this->formatClassName($this->_curModule, $className);
     }
     /**
      * Load the controller class file
      */
     $className = $this->loadClass($className);
     $controller = new $moduleClassName($request, $this->getResponse(), $this->getParams());
     // Code edited for PHP-DI
     // -----------------------------------------------
     // Inject the dependencies on the controller
     $this->container->injectOn($controller);
     // -----------------------------------------------
     if (!$controller instanceof Zend_Controller_Action_Interface && !$controller instanceof Zend_Controller_Action) {
         require_once 'Zend/Controller/Dispatcher/Exception.php';
         throw new Zend_Controller_Dispatcher_Exception('Controller "' . $moduleClassName . '" is not an instance of Zend_Controller_Action_Interface');
     }
     /**
      * Retrieve the action name
      */
     $action = $this->getActionMethod($request);
     /**
      * Dispatch the method call
      */
     $request->setDispatched(true);
     // by default, buffer output
     $disableOb = $this->getParam('disableOutputBuffering');
     $obLevel = ob_get_level();
     if (empty($disableOb)) {
         ob_start();
     }
     try {
         $controller->dispatch($action);
     } catch (Exception $e) {
         // Clean output buffer on error
         $curObLevel = ob_get_level();
         if ($curObLevel > $obLevel) {
             do {
                 ob_get_clean();
                 $curObLevel = ob_get_level();
             } while ($curObLevel > $obLevel);
         }
         throw $e;
     }
     if (empty($disableOb)) {
         $content = ob_get_clean();
         $response->appendBody($content);
     }
     // Destroy the page controller instance and reflection objects
     $controller = null;
 }
開發者ID:mnapoli,項目名稱:php-di-zf1,代碼行數:81,代碼來源:Dispatcher.php

示例3: init

 public function init()
 {
     parent::init();
     // inject dependencies to action controller
     $this->container->injectOn($this->getActionController());
 }
開發者ID:diePartments,項目名稱:pimcore-dependency-injection-plugin,代碼行數:6,代碼來源:DI.php


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