Prado\TApplicationConfiguration::loadFromFile PHP Метод

loadFromFile() публичный Метод

Parses the application configuration file.
public loadFromFile ( $fname )
    public function loadFromFile($fname)
    {
        if (Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) {
            $fcontent = (include $fname);
            $this->loadFromPhp($fcontent, dirname($fname));
        } else {
            $dom = new TXmlDocument();
            $dom->loadFromFile($fname);
            $this->loadFromXml($dom, dirname($fname));
        }
    }

Usage Example

Пример #1
0
 /**
  * Loads configuration and initializes application.
  * Configuration file will be read and parsed (if a valid cached version exists,
  * it will be used instead). Then, modules are created and initialized;
  * Afterwards, the requested service is created and initialized.
  * @param string configuration file path (absolute or relative to current executing script)
  * @param string cache file path, empty if no present or needed
  * @throws TConfigurationException if module is redefined of invalid type, or service not defined or of invalid type
  */
 protected function initApplication()
 {
     Prado::trace('Initializing application', 'Prado\\TApplication');
     if ($this->_configFile !== null) {
         if ($this->_cacheFile === null || @filemtime($this->_cacheFile) < filemtime($this->_configFile)) {
             $config = new TApplicationConfiguration();
             $config->loadFromFile($this->_configFile);
             if ($this->_cacheFile !== null) {
                 file_put_contents($this->_cacheFile, serialize($config), LOCK_EX);
             }
         } else {
             $config = unserialize(file_get_contents($this->_cacheFile));
         }
         $this->applyConfiguration($config, false);
     }
     if (($serviceID = $this->getRequest()->resolveRequest(array_keys($this->_services))) === null) {
         $serviceID = $this->getPageServiceID();
     }
     $this->startService($serviceID);
 }