本文整理汇总了PHP中static::config方法的典型用法代码示例。如果您正苦于以下问题:PHP static::config方法的具体用法?PHP static::config怎么用?PHP static::config使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类static
的用法示例。
在下文中一共展示了static::config方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public static function init()
{
// Load the user-defined test configuration file, if it exists; otherwise, load
if (is_readable(__DIR__ . '/TestConfig.php')) {
$testConfig = (include __DIR__ . '/TestConfig.php');
} else {
$testConfig = (include __DIR__ . '/TestConfig.php.dist');
}
$zf2ModulePaths = array();
if (isset($testConfig['module_listener_options']['module_paths'])) {
$modulePaths = $testConfig['module_listener_options']['module_paths'];
foreach ($modulePaths as $modulePath) {
if ($path = static::findParentPath($modulePath)) {
$zf2ModulePaths[] = $path;
}
}
}
$zf2ModulePaths = implode(PATH_SEPARATOR, $zf2ModulePaths) . PATH_SEPARATOR;
$zf2ModulePaths .= getenv('ZF2_MODULES_TEST_PATHS') ?: (defined('ZF2_MODULES_TEST_PATHS') ? ZF2_MODULES_TEST_PATHS : '');
static::initAutoloader();
// use ModuleManager to load this module and it's dependencies
$baseConfig = array('module_listener_options' => array('module_paths' => explode(PATH_SEPARATOR, $zf2ModulePaths)));
$config = ArrayUtils::merge($baseConfig, $testConfig);
$serviceManager = new ServiceManager(new ServiceManagerConfig());
$serviceManager->setService('ApplicationConfig', $config);
$serviceManager->get('ModuleManager')->loadModules();
static::$serviceManager = $serviceManager;
static::$config = $config;
}
示例2: 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();
}
示例3: getConfig
public static function getConfig($key = null)
{
if (!static::$config) {
$file = static::getConfigJson();
if (!file_exists($file)) {
file_put_contents($file, json_encode(Yaml::parse(static::getConfigYml())));
}
static::$config = json_decode(file_get_contents($file), true);
static::_bindConfig(self::$config);
static::_bindConfig(self::$config);
}
if (!$key) {
return static::$config;
}
if (array_key_exists($key, static::$config)) {
return static::$config[$key];
}
if (strpos($key, '.') !== false) {
$parts = explode('.', $key, 2);
$data = static::getConfig($parts[0]);
$data = UtilArray::cascadeGet($data, $parts[1]);
if ($data) {
return $data;
}
}
throw new Exception("Config '{$key}' not found");
}
示例4: _init
/**
* Initialize
*/
public static function _init()
{
$config = \Config::load('sentry', true);
static::$config = $config[\Fuel::$env];
// create instance for PHP
static::$client = new \Raven_Client(static::$config['php']['dsn']);
}
示例5: getInstance
public static function getInstance()
{
if (!static::$config) {
static::$config = static::factory(array("path" => static::$path));
}
return static::$config;
}
示例6: _init
/**
* Load configurations
*
* @static
* @access public
* @return void
*/
public static function _init()
{
if (null === static::$config) {
Config::load('hybrid', 'hybrid');
static::$config = Config::get('hybrid.template', array());
}
}
示例7: init
public static function init()
{
// Load the user-defined test configuration file, if it exists; otherwise, load
if (is_readable(__DIR__ . '/application.config.php')) {
$testConfig = (include __DIR__ . '/application.config.php');
} else {
$testConfig = (include __DIR__ . '/application.config.php.dist');
}
chdir(__DIR__ . '/..');
$zf2ModulePaths = array();
if (isset($testConfig['module_listener_options']['module_paths'])) {
$modulePaths = $testConfig['module_listener_options']['module_paths'];
foreach ($modulePaths as $modulePath) {
if ($path = static::findParentPath($modulePath)) {
$zf2ModulePaths[] = $path;
}
}
}
$zf2ModulePaths = implode(PATH_SEPARATOR, $zf2ModulePaths) . PATH_SEPARATOR;
$zf2ModulePaths .= getenv('ZF2_MODULES_TEST_PATHS') ?: (defined('ZF2_MODULES_TEST_PATHS') ? ZF2_MODULES_TEST_PATHS : '');
static::initAutoloader();
// use ModuleManager to load this module and it's dependencies
$baseConfig = array('module_listener_options' => array('module_paths' => explode(PATH_SEPARATOR, $zf2ModulePaths)));
$config = ArrayUtils::merge($baseConfig, $testConfig);
$serviceManager = new ServiceManager(new ServiceManagerConfig());
$serviceManager->setService('ApplicationConfig', $config);
$serviceManager->get('ModuleManager')->loadModules();
$entityManager = $serviceManager->get('doctrine.entitymanager.orm_default');
$eventManager = $entityManager->getEventManager();
$eventManager->addEventSubscriber(new \Aaa\EntityEvents\PrePersistListener(null));
static::$eventManager = $eventManager;
static::$serviceManager = $serviceManager;
static::$config = $config;
// static::createSchemaFromEntities();
}
示例8: parse
/**
* parse a yml config file and return the result.
*
* @param $path
* The yml config file path
*
* @param $sub (optional)
* An associative array of substitutions to recursively apply. This is
* used to simulate "variables" in the config, mostly for paths like
* APPDIR etc.
*
* @return
* The parsed result
*/
public static function parse($path, $sub)
{
$yaml = new Parser();
$parsed = $yaml->parse(file_get_contents($path));
static::$config = static::substitute($parsed, $sub);
return static::$config;
}
示例9: load_configs
protected static function load_configs()
{
static::$config = \Config::get('contexy::config');
foreach (static::$config as $key => $value) {
static::${$key} = $value;
}
}
示例10: config
public static function config($key = null, $default = null)
{
if (!static::$config instanceof Config) {
static::$config = new Config(static::path('src/config/'));
}
return is_null($key) ? static::$config : static::$config->get($key, $default);
}
示例11: __construct
public function __construct($config = [])
{
static::$config = $config;
static::setAlias('web', $config['web']);
static::setAlias('path', $config['path']);
static::setAlias('gbox', static::getAlias('path') . '/gbox');
static::setAlias('controllers', static::getAlias('gbox') . '/controllers');
static::setAlias('components', static::getAlias('gbox') . '/components');
static::setAlias('plugins', static::getAlias('gbox') . '/plugins');
static::setAlias('modules', static::getAlias('gbox') . '/modules');
static::setAlias('models', static::getAlias('gbox') . '/models');
static::setAlias('views', static::getAlias('gbox') . '/views');
static::setAlias('tmp', static::getAlias('gbox') . '/tmp');
static::setAlias('layouts', static::getAlias('views') . '/layouts');
static::setAlias('uploads-path', static::getAlias('path') . '/uploads');
static::setAlias('uploads', static::getAlias('web') . '/uploads');
static::setAlias('images', static::getAlias('web') . '/assets' . '/images');
static::setAlias('fonts', static::getAlias('web') . '/assets' . '/fonts');
static::setAlias('css', static::getAlias('web') . '/assets' . '/css');
static::setAlias('js', static::getAlias('web') . '/assets' . '/js');
session_save_path(realpath(Url::to('@tmp')));
Session::init();
if (property_exists(static::getConfig(), 'timezone')) {
date_default_timezone_set(static::getConfig()->timezone);
} else {
date_default_timezone_set('America/Montevideo');
}
}
示例12: _init
public static function _init()
{
static::$crypter = new Crypt_AES();
static::$hasher = new Crypt_Hash('sha256');
// load the config
\Config::load('crypt', true);
static::$config = \Config::get('crypt', array());
// generate random crypto keys if we don't have them or they are incorrect length
$update = false;
foreach (array('crypto_key', 'crypto_iv', 'crypto_hmac') as $key) {
if (empty(static::$config[$key]) or strlen(static::$config[$key]) % 4 != 0) {
$crypto = '';
for ($i = 0; $i < 8; $i++) {
$crypto .= static::safe_b64encode(pack('n', mt_rand(0, 0xffff)));
}
static::$config[$key] = $crypto;
$update = true;
}
}
// update the config if needed
if ($update === true) {
// load the file config
\Config::load('file', true);
try {
\Config::save('crypt', static::$config);
chmod(APPPATH . 'config' . DS . 'crypt.php', \Config::get('file.chmod.files', 0666));
} catch (\FileAccessException $e) {
// failed to write the config file, inform the user
echo \View::forge('errors/crypt_keys', array('keys' => static::$config));
die;
}
}
static::$crypter->enableContinuousBuffer();
static::$hasher->setKey(static::safe_b64decode(static::$config['crypto_hmac']));
}
示例13: init
public static function init()
{
$test_config = (include is_readable('TestConfig.php') ? 'TestConfig.php' : 'TestConfig.php.dist');
$test_config['module_listener_options']['config_cache_enabled'] = false;
$test_config['module_listener_options']['module_map_cache_enabled'] = false;
$zf2ModulePaths = array();
if (isset($test_config['module_listener_options']['module_paths'])) {
$modulePaths = $test_config['module_listener_options']['module_paths'];
foreach ($modulePaths as $modulePath) {
$path = static::findParentPath($modulePath);
if (false !== $path) {
$zf2ModulePaths[] = $path;
}
}
}
$zf2ModulePaths = implode(PATH_SEPARATOR, $zf2ModulePaths) . PATH_SEPARATOR;
$zf2ModulePaths .= getenv('ZF2_MODULES_TEST_PATHS') ?: (defined('ZF2_MODULES_TEST_PATHS') ? ZF2_MODULES_TEST_PATHS : '');
static::initAutoloader();
// use ModuleManager to load this module and it's dependencies
$baseConfig = array('module_listener_options' => array('module_paths' => explode(PATH_SEPARATOR, $zf2ModulePaths)));
$config = ArrayUtils::merge($baseConfig, $test_config);
$serviceManager = new ServiceManager(new ServiceManagerConfig());
$serviceManager->setService('ApplicationConfig', $config);
$serviceManager->get('ModuleManager')->loadModules();
static::$serviceManager = $serviceManager;
static::$config = $config;
}
示例14: getConfig
/**
* get the contents of the config.php file as array
* @return array
*/
protected static function getConfig()
{
if (empty(static::$config)) {
static::$config = (require WINKFORM_PATH . 'config.php');
}
return static::$config;
}
示例15: _init
public static function _init()
{
static::$config = Yaml::parse(file_get_contents(core_config_path() . '/api.yaml'));
foreach (static::$config as $k => $v) {
static::$keys[$k] = $v;
}
}