本文整理汇总了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']);
}
示例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;
});
}
示例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();
}
示例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);
}
示例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'));
});
}
示例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;
}
示例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);
});
}
示例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;
}
示例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;
});
}
示例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;
});
}
示例11: register
public static function register(Di $di)
{
static::$di = $di;
$di->remove('service');
$di->setShared('service', function () {
return new static(Config::get('service'));
});
}
示例12: register
public static function register(Di $di)
{
static::$di = $di;
$di->remove('router');
$di->setShared('router', function () {
return new static();
});
}
示例13: __construct
private function __construct()
{
static::$di = new Di(new DefinitionList([new ArrayDefinition($this->getDefinition()), new RuntimeDefinition()]));
}
示例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'));
});
}
示例15: unsetDi
/**
* Unsets the di container by setting the static variable to null
*/
public static function unsetDi()
{
static::$di = null;
}