Example #1
0
 /**
  * Reads the contents of the supplied file and applies it to this object.
  */
 public function makeConfig($configFile = [], $requiredConfig = [])
 {
     /*
      * Config already made
      */
     if (is_object($configFile)) {
         $config = $configFile;
         /*
          * Embedded config
          */
     } elseif (is_array($configFile)) {
         $config = $this->makeConfigFromArray($configFile);
         /*
          * Process config from file contents
          */
     } else {
         if (isset($this->controller) && method_exists($this->controller, 'getConfigPath')) {
             $configFile = $this->controller->getConfigPath($configFile);
         } else {
             $configFile = $this->getConfigPath($configFile);
         }
         if (!File::isFile($configFile)) {
             throw new SystemException(Lang::get('system::lang.config.not_found', ['file' => $configFile, 'location' => get_called_class()]));
         }
         $config = Yaml::parse(File::get($configFile));
         /*
          * Extensibility
          */
         $publicFile = File::localToPublic($configFile);
         if ($results = Event::fire('system.extendConfigFile', [$publicFile, $config])) {
             foreach ($results as $result) {
                 if (!is_array($result)) {
                     continue;
                 }
                 $config = array_merge($config, $result);
             }
         }
         $config = $this->makeConfigFromArray($config);
     }
     /*
      * Validate required configuration
      */
     foreach ($requiredConfig as $property) {
         if (!property_exists($config, $property)) {
             throw new SystemException(Lang::get('system::lang.config.required', ['property' => $property, 'location' => get_called_class()]));
         }
     }
     return $config;
 }
 /**
  * Returns all versions of a plugin from its version file.
  */
 protected function getFileVersions($code)
 {
     if ($this->fileVersions !== null && array_key_exists($code, $this->fileVersions)) {
         return $this->fileVersions[$code];
     }
     $versionFile = $this->getVersionFile($code);
     $versionInfo = Yaml::parseFile($versionFile);
     if ($versionInfo) {
         uksort($versionInfo, function ($a, $b) {
             return version_compare($a, $b);
         });
     }
     return $this->fileVersions[$code] = $versionInfo;
 }
Example #3
0
 /**
  * Reads the theme.yaml file and returns the theme configuration values.
  * @return array Returns the parsed configuration file values.
  */
 public function getConfig()
 {
     if ($this->configCache !== null) {
         return $this->configCache;
     }
     $path = $this->getPath() . '/theme.yaml';
     if (!File::exists($path)) {
         return $this->configCache = [];
     }
     return $this->configCache = Yaml::parseFile($path);
 }