/**
  * Constructor.
  * Reads the configuration given in the app spec.
  * In particular, the attribute 'enabled' and 'path' are read.
  * @param mixed the configuration.
  */
 function __construct($config)
 {
     if (isset($config['enabled']) && (string) $config['enabled'] == 'true') {
         $this->enabled = true;
     } else {
         $this->enabled = false;
     }
     if (empty($config['path'])) {
         $this->rootPath = null;
     } else {
         $this->rootPath = realpath(pradoGetContextPath((string) $config['path'], dirname(pradoGetApplication()->getSpecificationFile())));
         if ($this->rootPath === false || !is_dir($this->rootPath)) {
             throw new Exception("Unable to locate the cache path '{$this->rootPath}'.");
         }
     }
     $this->savePath = $this->rootPath;
 }
 /**
  * Reads the configuration for defining user parameters.
  * @param mixed the parameter configuration
  * @param string the parameter file path
  * @return array list of user parameters.
  */
 protected function readParameterConfig($config, $filePath = '')
 {
     static $recursion = 0;
     $recursion++;
     if ($recursion > 5) {
         // we allow recursive param file inclusion at most 5 levels.
         throw new Exception("Maximum parameter file inclusion level reached.");
     }
     $parameters = array();
     $contextPath = dirname($this->specificationFile);
     foreach ($config as $parameter) {
         $name = (string) $parameter['name'];
         $file = (string) $parameter['file'];
         $contextPath = strlen($filePath) ? dirname($filePath) : dirname($this->specificationFile);
         if (strlen($name)) {
             $parameters[$name] = $this->parseXMLParameters($parameter);
         } else {
             if (strlen($file)) {
                 $paramFile = realpath(pradoGetContextPath($file, $contextPath));
                 if ($paramFile === false || !is_file($paramFile)) {
                     throw new Exception("Parameter file '{$file}' does not exist.");
                 }
                 $paramXML = simplexml_load_file($paramFile);
                 if ($paramXML === false) {
                     throw new Exception("Error in parsing parameter file '{$file}'.");
                 }
                 $ps = $this->readParameterConfig($paramXML->parameter, $paramFile);
                 $parameters = array_merge($parameters, $ps);
             }
         }
     }
     $recursion--;
     return $parameters;
 }