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


PHP DI::setShared方法代碼示例

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


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

示例1: setUp

 /**
  * Set up test vars
  *
  * @return void
  * @author Dan Cox
  */
 public function setUp()
 {
     $di = new DI();
     $di->setShared('output', new Output());
     $di->setShared('input', new Input());
     $this->helpers = new Helpers($di);
 }
開發者ID:danzabar,項目名稱:phalcon-cli,代碼行數:13,代碼來源:HelperTest.php

示例2: setUp

 public function setUp()
 {
     $this->di = \Phalcon\DI::getDefault();
     $this->di->setShared('environment', function () {
         return \Vegas\Constants::TEST_ENV;
     });
     $this->di->setShared('view', function () {
         return 'fake-view';
     });
 }
開發者ID:vegas-cmf,項目名稱:profiler,代碼行數:10,代碼來源:ManagerTest.php

示例3: registerServices

 /**
  * @param DI $di
  */
 public function registerServices($di)
 {
     //Registering a dispatcher
     $di->setShared('dispatcher', function () use($di) {
         $dispatcher = new Dispatcher();
         $dispatcher->setDefaultNamespace("Admin");
         $eventsManager = $di->getShared('eventsManager');
         $eventsManager->attach('dispatch', new AdminSecurity($di));
         $dispatcher->setEventsManager($eventsManager);
         return $dispatcher;
     });
     $auto_admin = new \AutoAdmin\Module();
     $auto_admin->registerServices($di);
     $di->setShared('admin_views_dir', function () {
         return ADMINROOT . '/views/';
     });
     $di->setShared('session', function () {
         $session = new Session();
         $session->start();
         return $session;
     });
     $di->setShared('config', function () use($di) {
         $configFront = (require COREROOT . '/app/config/config.php');
         $configBack = (require ADMINROOT . '/config/config.php');
         $configFront->merge($configBack);
         return $configFront;
     });
 }
開發者ID:moaljazaery,項目名稱:phalcon-module-admin,代碼行數:31,代碼來源:module.php

示例4: setUp

 /**
  * Initialize testing object
  *
  * @uses Auth
  * @uses \ReflectionClass
  */
 public function setUp()
 {
     $this->di = new FactoryDefault();
     $this->di->reset();
     // Setup DI
     $this->di = new DI();
     $this->di->setShared('session', function () {
         $session = new \Phalcon\Session\Adapter\Files();
         $session->start();
         return $session;
     });
     $this->di->set('tag', function () {
         $tag = new \Phalcon\Tag();
         return $tag;
     });
     $this->di->set('escaper', function () {
         $escaper = new \Phalcon\Escaper();
         return $escaper;
     });
     DI::setDefault($this->di);
     $this->reflection = new \ReflectionClass('ULogin\\Auth');
     $this->auth = new Auth();
 }
開發者ID:stanislav-web,項目名稱:phalcon-ulogin,代碼行數:29,代碼來源:AuthTest.php

示例5: __construct

 /**
  * @param Router|null $router
  * @param Url|null $url
  */
 public function __construct(Router $router = null, Url $url = null)
 {
     $di = new DI();
     $di->setShared('request', new PhalconRequest());
     if ($router instanceof PhalconRouterInterface) {
         $this->router = $router;
     } elseif ($router === null) {
         $this->router = new Router();
         $this->router->clear();
     } else {
         throw new Exception\RuntimeException('Router has to be an instance of RouterInterface');
     }
     $this->router->setDI($di);
     $di->setShared('router', $this->router);
     if ($url instanceof UrlInterface) {
         $this->url = $url;
     } elseif ($url === null) {
         $this->url = new Url();
         $this->url->setBaseUri('/');
     } else {
         throw new Exception\RuntimeException('Url has to be an instance of UrlInterface');
     }
     $this->url->setDI($di);
 }
開發者ID:theDisco,項目名稱:phalcon-expressive,代碼行數:28,代碼來源:PhalconRouter.php

示例6: _initEngine

 /**
  * Init engine.
  *
  * @param DI $di Dependency Injection.
  *
  * @return void
  */
 protected function _initEngine($di)
 {
     $di->setShared('transactions', function () {
         $manager = new TxManager();
         return $manager->setDbService("dbMaster");
     });
 }
開發者ID:swordkee,項目名稱:phalcon-demo,代碼行數:14,代碼來源:ApplicationMicro.php

示例7: registerServices

 /**
  * Registration services for specific module
  * @param \Phalcon\DI $di
  * @access public
  * @return mixed
  */
 public function registerServices($di)
 {
     // Dispatch register
     $di->set('dispatcher', function () use($di) {
         $eventsManager = $di->getShared('eventsManager');
         $eventsManager->attach('dispatch:beforeException', new \Plugins\Dispatcher\NotFoundPlugin());
         $dispatcher = new \Phalcon\Mvc\Dispatcher();
         $dispatcher->setEventsManager($eventsManager);
         $dispatcher->setDefaultNamespace('Modules\\' . self::MODULE . '\\Controllers');
         return $dispatcher;
     }, true);
     // Registration of component representations (Views)
     $di->set('view', function () {
         $view = new View();
         $view->setViewsDir($this->_config['application']['viewsBack'])->setMainView('auth-layout')->setPartialsDir('partials');
         return $view;
     });
     require_once APP_PATH . '/Modules/' . self::MODULE . '/config/services.php';
     // call profiler
     if ($this->_config->database->profiler === true) {
         new \Plugins\Debugger\Develop($di);
     }
     if (APPLICATION_ENV == 'development') {
         // share Fabfuel topbar
         $profiler = new \Fabfuel\Prophiler\Profiler();
         $di->setShared('profiler', $profiler);
         $pluginManager = new \Fabfuel\Prophiler\Plugin\Manager\Phalcon($profiler);
         $pluginManager->register();
         // add toolbar in your basic BaseController
     }
     return;
 }
開發者ID:stanislav-web,項目名稱:phalcon-development,代碼行數:38,代碼來源:Module.php

示例8: _initSession

 /**
  * Init session.
  *
  * @param DI     $di     Dependency Injection.
  * @param Config $config Config object.
  *
  * @return SessionAdapter
  */
 protected function _initSession($di, $config)
 {
     $session = new \Phalcon\Session\Adapter\Redis(['path' => "tcp://127.0.0.1:6379?weight=1", 'persistent' => false, 'lifetime' => 3600, 'prefix' => '_haraapp_']);
     $session->start();
     $di->setShared('session', $session);
     return $session;
 }
開發者ID:nguyenducduy,項目名稱:haraapp,代碼行數:15,代碼來源:Init.php

示例9: buildContainer

 private function buildContainer()
 {
     $container = new Container();
     $container->setShared('service_container', $container);
     $container->setShared('config', $this->config);
     foreach ($this->getServices() as $name => $definition) {
         $container->setShared($name, $definition);
     }
     return $container;
 }
開發者ID:nexik,項目名稱:nest-core,代碼行數:10,代碼來源:Application.php

示例10: _initEngine

 /**
  * Init engine.
  *
  * @param DI $di Dependency Injection.
  *
  * @return void
  */
 protected function _initEngine($di)
 {
     foreach ($di->get('registry')->modules as $module) {
         // Initialize module api.
         $di->setShared(strtolower($module), function () use($module, $di) {
             return new ApiInjector($module, $di);
         });
     }
     $di->setShared('transactions', function () {
         return new TxManager();
     });
     $di->setShared('assets', new AssetsManager($di));
     $di->setShared('widgets', new Catalog());
 }
開發者ID:biggtfish,項目名稱:cms,代碼行數:21,代碼來源:ApplicationInitialization.php

示例11: registerConfigurations

 /**
  * Register configurations
  * @param  Phalcon\DI $di
  */
 private function registerConfigurations($di)
 {
     $di->setShared('config', function () {
         return new \Phalcon\Config\Adapter\Ini(self::CONFIG_FILE);
     });
 }
開發者ID:enriqueojedalara,項目名稱:reddit-demo,代碼行數:10,代碼來源:Module.php

示例12: _initSession

 /**
  * Init session.
  *
  * @param DI     $di     Dependency Injection.
  * @param Config $config Config object.
  *
  * @return SessionAdapter
  */
 protected function _initSession($di, $config)
 {
     $session = new PhSessionFiles();
     $session->start();
     $di->setShared('session', $session);
     return $session;
 }
開發者ID:nguyenducduy,項目名稱:phblog,代碼行數:15,代碼來源:Init.php


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