cascade\Cascade::fileConfig PHP Method

fileConfig() public static method

Load configuration options from a file or a string
public static fileConfig ( string $resource )
$resource string Path to config file or string or array
    public static function fileConfig($resource)
    {
        self::$config = new Config($resource, new ConfigLoader());
        self::$config->load();
        self::$config->configure();
    }

Usage Example

示例#1
0
 /**
  * Configure Cascaded Monolog logger and use it.
  *
  * @param        $configFile
  * @param string $loggerName
  */
 private function _initLoggerCascade($configFile, $loggerName)
 {
     $err = '';
     try {
         $fs = $this->_obm->get(Filesystem::class);
         if ($fs->isAbsolutePath($configFile)) {
             $fileName = $configFile;
         } else {
             $fileName = BP . '/' . $configFile;
         }
         $realPath = realpath($fileName);
         if ($realPath) {
             Cascade::fileConfig($realPath);
             $this->_logger = Cascade::getLogger($loggerName);
         } else {
             $err = "Cannot open logging configuration file '{$fileName}'. Default Magento logger is used.";
         }
     } catch (\Exception $e) {
         $err = $e->getMessage();
     } finally {
         if (is_null($this->_logger)) {
             $this->_logger = $this->_obm->get(\Magento\Framework\Logger\Monolog::class);
             $this->warning($err);
         }
     }
 }
All Usage Examples Of cascade\Cascade::fileConfig