当前位置: 首页>>代码示例>>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;未经允许,请勿转载。