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


PHP Di::remove方法代码示例

本文整理汇总了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
    }
开发者ID:phwoolcon,项目名称:phwoolcon,代码行数:33,代码来源:Config.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;
     $di->remove('payment');
     static::$instance = null;
     $di->setShared('payment', function () {
         return new static(Config::get('payment'));
     });
 }
开发者ID:phwoolcon,项目名称:payment,代码行数:9,代码来源:Processor.php

示例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);
     });
 }
开发者ID:phwoolcon,项目名称:phwoolcon,代码行数:14,代码来源:Counter.php

示例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;
     });
 }
开发者ID:phwoolcon,项目名称:phwoolcon,代码行数:18,代码来源:Log.php

示例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;
     });
 }
开发者ID:phwoolcon,项目名称:phwoolcon,代码行数:18,代码来源:Cache.php

示例7: 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

示例8: remove

 public function remove($name)
 {
     parent::remove($name);
 }
开发者ID:mattvb91,项目名称:cphalcon,代码行数:4,代码来源:Di.php

示例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();
     });
 }
开发者ID:phwoolcon,项目名称:phwoolcon,代码行数:14,代码来源:Db.php

示例10: 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


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