本文整理汇总了PHP中Phalcon\Di::remove方法的典型用法代码示例。如果您正苦于以下问题:PHP Di::remove方法的具体用法?PHP Di::remove怎么用?PHP Di::remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phalcon\Di
的用法示例。
在下文中一共展示了Di::remove方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
public static function register(Di $di)
{
$environment = isset($_SERVER['PHWOOLCON_ENV']) ? $_SERVER['PHWOOLCON_ENV'] : 'production';
// @codeCoverageIgnoreStart
if (is_file($cacheFile = storagePath('cache/config-' . $environment . '.php'))) {
static::$config = (include $cacheFile);
Config::get('app.cache_config') or static::clearCache();
return;
}
// @codeCoverageIgnoreEnd
$defaultFiles = glob($_SERVER['PHWOOLCON_CONFIG_PATH'] . '/*.php');
$environmentFiles = glob($_SERVER['PHWOOLCON_CONFIG_PATH'] . '/' . $environment . '/*.php');
$config = new PhalconConfig(static::loadFiles($defaultFiles));
$environmentSettings = static::loadFiles($environmentFiles);
$environmentSettings['environment'] = $environment;
$environmentConfig = new PhalconConfig($environmentSettings);
$config->merge($environmentConfig);
$di->remove('config');
$di->setShared('config', $config);
static::$config = $config->toArray();
Config::get('database.default') and static::loadDb($config);
// @codeCoverageIgnoreStart
if (Config::get('app.cache_config')) {
is_dir($cacheDir = dirname($cacheFile)) or mkdir($cacheDir, 0777, true);
fileSaveArray($cacheFile, static::$config, function ($content) {
$replacement = <<<'EOF'
$_SERVER['PHWOOLCON_ROOT_PATH'] . '
EOF;
return str_replace("'{$_SERVER['PHWOOLCON_ROOT_PATH']}", $replacement, $content);
});
}
// @codeCoverageIgnoreEnd
}
示例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;
$di->remove('payment');
static::$instance = null;
$di->setShared('payment', function () {
return new static(Config::get('payment'));
});
}
示例4: 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);
});
}
示例5: register
public static function register(Di $di)
{
static::$hostname = gethostname();
$di->remove('log');
static::$logger = null;
$di->setShared('log', function () {
$filePath = storagePath('logs');
is_dir($filePath) or mkdir($filePath, 0777, true);
$filePath .= '/' . Config::get('app.log.file', 'phwoolcon.log');
$logger = new File($filePath);
$formatter = $logger->getFormatter();
if ($formatter instanceof Line) {
$formatter->setDateFormat('Y-m-d H:i:s');
$formatter->setFormat('[%date%]{host}[%type%] {request} %message%');
}
return $logger;
});
}
示例6: 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;
});
}
示例7: register
public static function register(Di $di)
{
static::$di = $di;
$di->remove('router');
$di->setShared('router', function () {
return new static();
});
}
示例8: remove
public function remove($name)
{
parent::remove($name);
}
示例9: register
public static function register(Di $di)
{
static::$di = $di;
$di->remove('modelsMetadata');
$di->setShared('modelsMetadata', function () {
return new InCache();
});
$di->setShared('dbManager', function () {
return new static(Config::get('database'));
});
$di->setShared('db', function () {
return static::connection();
});
}
示例10: register
public static function register(Di $di)
{
static::$di = $di;
$di->remove('service');
$di->setShared('service', function () {
return new static(Config::get('service'));
});
}