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;
 }
Example #2
0
 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();
 }
Example #3
0
 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");
 }
 /**
  * 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']);
 }
Example #5
0
 public static function getInstance()
 {
     if (!static::$config) {
         static::$config = static::factory(array("path" => static::$path));
     }
     return static::$config;
 }
Example #6
0
 /**
  * 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());
     }
 }
Example #7
0
 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();
 }
 /**
  * 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;
 }
Example #9
0
 protected static function load_configs()
 {
     static::$config = \Config::get('contexy::config');
     foreach (static::$config as $key => $value) {
         static::${$key} = $value;
     }
 }
Example #10
0
 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);
 }
Example #11
0
 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');
     }
 }
Example #12
0
 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']));
 }
Example #13
0
 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;
 }
Example #14
0
 /**
  * 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;
 }
Example #15
0
 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;
     }
 }
Example #16
0
    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
    }
Example #17
0
 public static function setConfig($config)
 {
     $instance = static::getInstance();
     static::$current = $config['default'];
     static::$config = $config;
     return $instance;
 }
Example #18
0
 /**
  * 根据业务组名获取配置key前缀
  * @param $group
  * @return string
  */
 public static function getKeyPrefix($group)
 {
     if (empty(static::$config)) {
         static::$config = static::loadRedisConfig();
     }
     return static::_getKeyPrefix($group);
 }
Example #19
0
 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]) || 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) {
         try {
             \Config::save('crypt', static::$config);
         } catch (\File_Exception $e) {
             throw new \Exception('Crypt keys are invalid or missing, and app/config/crypt.php could not be written.');
         }
     }
     static::$crypter->enableContinuousBuffer();
     static::$hasher->setKey(static::safe_b64decode(static::$config['crypto_hmac']));
 }
Example #20
0
 /**
  * Initialize the config for database(s)
  */
 public static function init()
 {
     if (static::$config === null) {
         static::$config = Application::getConfig('database');
         $keys = array_keys(static::$config);
         static::$defaultKey = $keys[0];
     }
 }
Example #21
0
 /**
  * Static init
  *
  * @return void
  */
 public static function _init()
 {
     // select the current builder
     $builder_class = \ClanCats::$config->get('ui.builder', "\\UI\\Builder_Bootstrap");
     static::$builder = new $builder_class();
     // load the ui configuration
     static::$config = \CCConfig::create('ui');
 }
 /**
  * Loads connections configuration.
  *
  * @return void
  */
 protected static function _init()
 {
     include_once APP . 'Config' . DS . 'database.php';
     if (class_exists('DATABASE_CONFIG')) {
         static::$config = new DATABASE_CONFIG();
     }
     static::$_init = true;
 }
Example #23
0
 /**
  * Will build the config class if needed
  *
  * @return boolean
  */
 public static function init()
 {
     if (!static::$isInit) {
         $ini = static::getIniString();
         static::$config = parse_ini_string($ini);
     }
     return static::$isInit = true;
 }
Example #24
0
 /**
  * Get config from file. Will get from cache if has loaded.
  *
  * @return  Registry Config object.
  */
 public static function getConfig()
 {
     if (static::$config instanceof Registry) {
         return static::$config;
     }
     $config = with(new Registry())->loadFile(static::getPath(), static::$type);
     return static::$config = $config;
 }
Example #25
0
 public static function get($key)
 {
     if (static::$config === null) {
         include APP_ROOT . static::CONFIG_FILE;
         static::$config = $emlauncher_config[mfwServerEnv::getEnv()];
     }
     return isset(static::$config[$key]) ? static::$config[$key] : null;
 }
Example #26
0
 /**
  * Return all global config values
  */
 public static function getConfigFile()
 {
     if (null == static::$config) {
         static::$config = (require '/' . APP_DIR . '/config/' . self::CONFIG_FILE . '.php');
         static::replaceParameters(static::$config);
     }
     return static::$config;
 }
Example #27
0
 /**
  * Method: loadIni
  * Loads the Configuration
  * @param string $path path to the config file
  */
 public static function loadIni($path)
 {
     try {
         static::$config = parse_ini_string(file_get_contents($path), true);
     } catch (Exception $e) {
         throw new CantAccessConfigFileException();
     }
 }
Example #28
0
 public static function config($option, $value = '')
 {
     if (is_array($option)) {
         static::$config = array_merge(static::$config, $option);
     } else {
         static::$config[$option] = $value;
     }
 }
Example #29
0
 protected static function getConfig()
 {
     if (null === static::$config) {
         $config = new Config(PATH_LOCAL . "/" . EMAIL_CONFIG_FILE);
         static::$config = $config;
     }
     return static::$config;
 }
 function let(ConfigFactoryInterface $configFactory, GeneratorConfigInterface $config)
 {
     static::$default = __DIR__ . "/../../../fixtures";
     static::$config = array('model' => $config);
     $this->beConstructedWith($configFactory);
     $config->generator()->willReturn('Here is the generator');
     $configFactory->create(getcwd(), static::$default, 'json')->willReturn(static::$config);
 }