loadFromFile() public méthode

Loads and parses an XML document.
public loadFromFile ( $file ) : boolean
Résultat boolean whether the XML file is parsed successfully
Exemple #1
0
 public function testLoadFromFile()
 {
     $file = dirname(__FILE__) . '/data/test.xml';
     $xmldoc = new TXmlDocument();
     try {
         $xmldoc->loadFromFile('unexistentXmlFile.xml');
         self::fail('Expected TIOException not thrown');
     } catch (TIOException $e) {
     }
     self::assertTrue($xmldoc->loadFromFile($file));
     self::assertEquals('1.0', $xmldoc->getVersion());
     self::assertEquals('UTF-8', $xmldoc->getEncoding());
 }
 /**
  * Parses the application configuration file.
  * @param string configuration file name
  * @throws TConfigurationException if there is any parsing error
  */
 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));
     }
 }
Exemple #3
0
 /**
  * Initializes this module.
  * This method is required by the IModule interface.
  * @param mixed configuration for this module, can be null
  * @throws TConfigurationException if {@link getConfigFile ConfigFile} is invalid.
  */
 public function init($config)
 {
     if ($this->_configFile !== null) {
         if (is_file($this->_configFile)) {
             if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) {
                 $phpConfig = (include $this->_configFile);
                 $this->loadConfig($phpConfig);
             } else {
                 $dom = new TXmlDocument();
                 $dom->loadFromFile($this->_configFile);
                 $this->loadConfig($dom);
             }
         } else {
             throw new TConfigurationException('logrouter_configfile_invalid', $this->_configFile);
         }
     }
     $this->loadConfig($config);
     $this->getApplication()->attachEventHandler('OnEndRequest', array($this, 'collectLogs'));
 }
Exemple #4
0
 /**
  * Initializes the module by loading parameters.
  * @param mixed content enclosed within the module tag
  */
 public function init($config)
 {
     $this->loadParameters($config);
     if ($this->_paramFile !== null) {
         $configFile = null;
         if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_XML && ($cache = $this->getApplication()->getCache()) !== null) {
             $cacheKey = 'TParameterModule:' . $this->_paramFile;
             if (($configFile = $cache->get($cacheKey)) === false) {
                 $configFile = new TXmlDocument();
                 $configFile->loadFromFile($this->_paramFile);
                 $cache->set($cacheKey, $configFile, 0, new TFileCacheDependency($this->_paramFile));
             }
         } else {
             if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) {
                 $configFile = (include $this->_paramFile);
             } else {
                 $configFile = new TXmlDocument();
                 $configFile->loadFromFile($this->_paramFile);
             }
         }
         $this->loadParameters($configFile);
     }
     $this->_initialized = true;
 }
Exemple #5
0
 /**
  * Initializes this module.
  * This method is required by the IModule interface.
  * @param TXmlElement configuration for this module, can be null
  * @throws TConfigurationException if {@link getConfigFile ConfigFile} is invalid.
  */
 public function init($config)
 {
     if ($this->_configFile !== null) {
         if (is_file($this->_configFile)) {
             $dom = new TXmlDocument();
             $dom->loadFromFile($this->_configFile);
             $this->loadConfig($dom);
         } else {
             throw new TConfigurationException('soapservice_configfile_invalid', $this->_configFile);
         }
     }
     $this->loadConfig($config);
     $this->resolveRequest();
 }
 /**
  * Loads a specific config file.
  * @param string config file name
  * @param string the page path that the config file is associated with. The page path doesn't include the page name.
  */
 public function loadFromFile($fname, $configPagePath)
 {
     Prado::trace("Loading page configuration file {$fname}", 'System.Web.Services.TPageService');
     if (empty($fname) || !is_file($fname)) {
         return;
     }
     if (Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) {
         $fcontent = (include $fname);
         $this->loadFromPhp($fcontent, dirname($fname), $configPagePath);
     } else {
         $dom = new TXmlDocument();
         if ($dom->loadFromFile($fname)) {
             $this->loadFromXml($dom, dirname($fname), $configPagePath);
         } else {
             throw new TConfigurationException('pageserviceconf_file_invalid', $fname);
         }
     }
 }
Exemple #7
0
 /**
  * Initialize the module from configuration file.
  * @throws TConfigurationException if {@link getConfigFile ConfigFile} is invalid.
  */
 protected function loadConfigFile()
 {
     if (is_file($this->_configFile)) {
         if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) {
             $config = (include $this->_configFile);
             $this->loadUrlMappings($dom);
         } else {
             $dom = new TXmlDocument();
             $dom->loadFromFile($this->_configFile);
             $this->loadUrlMappings($dom);
         }
     } else {
         throw new TConfigurationException('urlmapping_configfile_inexistent', $this->_configFile);
     }
 }
Exemple #8
0
 /**
  * Initializes the module.
  * This method is required by IModule and is invoked by application.
  * It loads user/role information from the module configuration.
  * @param mixed module configuration
  */
 public function init($config)
 {
     $this->loadUserData($config);
     if ($this->_userFile !== null) {
         if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) {
             $userFile = (include $this->_userFile);
             $this->loadUserDataFromPhp($userFile);
         } else {
             $dom = new TXmlDocument();
             $dom->loadFromFile($this->_userFile);
             $this->loadUserDataFromXml($dom);
         }
     }
     $this->_initialized = true;
 }