当前位置: 首页>>代码示例>>PHP>>正文


PHP static::di方法代码示例

本文整理汇总了PHP中static::di方法的典型用法代码示例。如果您正苦于以下问题:PHP static::di方法的具体用法?PHP static::di怎么用?PHP static::di使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在static的用法示例。


在下文中一共展示了static::di方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 public function setUp()
 {
     static::$di = new Di();
     Di::setDefault(static::$di);
     putenv('APP_ENV');
     unset($_ENV['APP_ENV'], $_SERVER['APP_ENV']);
 }
开发者ID:logikostech,项目名称:core,代码行数:7,代码来源:BootstrapTest.php

示例2: register

 public static function register(Di $di)
 {
     static::$di = $di;
     ini_set('session.use_cookies', 0);
     ini_set('session.cache_limiter', '');
     $di->remove('session');
     static::$session = null;
     $di->setShared('session', function () {
         $default = Config::get('session.default');
         $config = Config::get('session.drivers.' . $default);
         $class = $config['adapter'];
         $options = $config['options'];
         $options += Config::get('session.options');
         $options['cookies'] += Config::get('cookies');
         session_name($options['cookies']['name']);
         strpos($class, '\\') === false and $class = 'Phwoolcon\\Session\\Adapter\\' . $class;
         $session = new $class($options);
         // @codeCoverageIgnoreStart
         if (!$session instanceof AdapterInterface) {
             throw new SessionException('Session class should implement ' . AdapterInterface::class);
         }
         // @codeCoverageIgnoreEnd
         return $session;
     });
 }
开发者ID:phwoolcon,项目名称:phwoolcon,代码行数:25,代码来源:Session.php

示例3: register

 public static function register(Di $di)
 {
     static::$di = $di;
     static::$config = Config::get('auth');
     $di->setShared('auth', function () {
         $di = static::$di;
         $config = static::$config;
         $class = $config['adapter'];
         $options = $config['options'];
         strpos($class, '\\') === false and $class = 'Phwoolcon\\Auth\\Adapter\\' . $class;
         if ($di->has($class)) {
             $class = $di->getRaw($class);
         }
         if (!class_exists($class)) {
             throw new Exception('Admin auth adapter class should implement ' . AdapterInterface::class);
         }
         /* @var Security $hasher */
         $hasher = static::$di->getShared('security');
         $hasher->setDefaultHash($options['security']['default_hash']);
         $hasher->setWorkFactor($options['security']['work_factor']);
         $adapter = new $class($options, $hasher, $di);
         if (!$adapter instanceof AdapterInterface) {
             throw new Exception('Auth adapter class should implement ' . AdapterInterface::class);
         }
         return $adapter;
     });
     static::addPhwoolconJsOptions();
 }
开发者ID:phwoolcon,项目名称:auth,代码行数:28,代码来源:Auth.php

示例4: setUp

 public function setUp()
 {
     static::$di = new Di();
     Di::setDefault(static::$di);
     ini_set('display_errors', 1);
     ini_set('display_startup_errors', 1);
     error_reporting(E_ALL);
 }
开发者ID:logikostech,项目名称:core,代码行数:8,代码来源:ModulesTest.php

示例5: register

 public static function register(Di $di)
 {
     static::$di = $di;
     $di->remove('payment');
     static::$instance = null;
     $di->setShared('payment', function () {
         return new static(Config::get('payment'));
     });
 }
开发者ID:phwoolcon,项目名称:payment,代码行数:9,代码来源:Processor.php

示例6: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     $basedir = realpath(__DIR__ . '/../../../');
     $testdir = $basedir . '/tests';
     self::$viewsdir = realpath($testdir . '/views/') . '/';
     include_once $basedir . "/vendor/autoload.php";
     $di = new DI();
     static::$di = $di;
 }
开发者ID:logikostech,项目名称:forms,代码行数:9,代码来源:RadiosetTest.php

示例7: register

 public static function register(Di $di)
 {
     static::$di = $di;
     $di->remove('counter');
     static::$adapter = null;
     $di->setShared('counter', function () {
         $default = Config::get('counter.default');
         $config = Config::get('counter.drivers.' . $default);
         $class = $config['adapter'];
         $options = $config['options'];
         strpos($class, '\\') === false and $class = 'Phwoolcon\\Util\\Counter\\' . $class;
         return new $class($options);
     });
 }
开发者ID:phwoolcon,项目名称:phwoolcon,代码行数:14,代码来源:Counter.php

示例8: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     $basedir = realpath(__DIR__ . '/../../');
     $testdir = $basedir . '/tests';
     self::$viewsdir = realpath($testdir . '/views/') . '/';
     include_once $basedir . "/vendor/autoload.php";
     $di = new DI();
     $di->set('form', "Logikos\\Forms\\Form");
     $di->set('url', function () {
         $url = new \Phalcon\Mvc\Url();
         $url->setBaseUri('/');
         return $url;
     });
     static::$di = $di;
 }
开发者ID:logikostech,项目名称:forms,代码行数:15,代码来源:FormTest.php

示例9: register

 public static function register(Di $di)
 {
     static::$di = $di;
     $di->remove('cache');
     static::$cache = null;
     $di->setShared('cache', function () {
         $frontend = new Data(['lifetime' => static::TTL_ONE_DAY]);
         $default = Config::get('cache.default');
         $config = Config::get('cache.drivers.' . $default);
         $class = $config['adapter'];
         $options = $config['options'];
         strpos($class, '\\') === false and $class = 'Phalcon\\Cache\\Backend\\' . $class;
         isset($options['cacheDir']) and $options['cacheDir'] = storagePath($options['cacheDir']) . '/';
         /* @var Backend $backend */
         $backend = new $class($frontend, $options);
         return $backend;
     });
 }
开发者ID:phwoolcon,项目名称:phwoolcon,代码行数:18,代码来源:Cache.php

示例10: register

 public static function register(Di $di)
 {
     static::$di = $di;
     $di->set('Phalcon\\Http\\Cookie', 'Phwoolcon\\Http\\Cookie');
     static::$cookies = static::$di->getShared('cookies');
     static::$cookies->reset();
     static::$options = $options = Config::get('cookies');
     static::$cookies->useEncryption($encrypt = $options['encrypt']);
     $encrypt and static::$di->getShared('crypt')->setKey($options['encrypt_key'])->setPadding(Crypt::PADDING_ZERO);
     /* @var \Phalcon\Http\Response $response */
     if ($response = $di->getShared('response')) {
         $response->setCookies(static::$cookies);
     }
     Events::attach('view:generatePhwoolconJsOptions', function (Event $event) {
         $options = $event->getData() ?: [];
         $options['cookies'] = ['domain' => static::$options['domain'], 'path' => static::$options['path']];
         $event->setData($options);
         return $options;
     });
 }
开发者ID:phwoolcon,项目名称:phwoolcon,代码行数:20,代码来源:Cookies.php

示例11: register

 public static function register(Di $di)
 {
     static::$di = $di;
     $di->remove('service');
     $di->setShared('service', function () {
         return new static(Config::get('service'));
     });
 }
开发者ID:phwoolcon,项目名称:phwoolcon,代码行数:8,代码来源:Service.php

示例12: register

 public static function register(Di $di)
 {
     static::$di = $di;
     $di->remove('router');
     $di->setShared('router', function () {
         return new static();
     });
 }
开发者ID:phwoolcon,项目名称:phwoolcon,代码行数:8,代码来源:Router.php

示例13: __construct

 private function __construct()
 {
     static::$di = new Di(new DefinitionList([new ArrayDefinition($this->getDefinition()), new RuntimeDefinition()]));
 }
开发者ID:waydelyle,项目名称:mobicms,代码行数:4,代码来源:Container.php

示例14: register

 public static function register(Di $di)
 {
     static::$di = $di;
     static::$runningUnitTest = Config::runningUnitTest();
     $di->setShared('view', function () {
         return new static(Config::get('view'));
     });
 }
开发者ID:phwoolcon,项目名称:phwoolcon,代码行数:8,代码来源:View.php

示例15: unsetDi

 /**
  * Unsets the di container by setting the static variable to null
  */
 public static function unsetDi()
 {
     static::$di = null;
 }
开发者ID:codenamephp,项目名称:prototype.library.platform,代码行数:7,代码来源:Installer.php


注:本文中的static::di方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。