當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。