/** * Handle an event. * * @param \League\Event\EventInterface $event The triggering event * * @return void * @see \League\Event\ListenerInterface::handle() */ public function handle(EventInterface $event) { try { // load the application server and the naming directory instance /** @var \AppserverIo\Appserver\Core\Interfaces\ApplicationServerInterface $applicationServer */ $applicationServer = $this->getApplicationServer(); /** @var \AppserverIo\Psr\Naming\NamingDirectoryInterface $namingDirectory */ $namingDirectory = $applicationServer->getNamingDirectory(); // initialize configuration and schema file name $configurationFileName = $applicationServer->getConfigurationFilename(); // get an instance of our configuration tester $configurationService = new ConfigurationService(new InitialContext(new AppserverNode())); // load the parsed system configuration /** @var \DOMDocument $doc */ $doc = $configurationService->loadConfigurationByFilename($configurationFileName); // validate the configuration file with the schema $configurationService->validateXml($doc, null, true); try { // query whether we're in configuration test mode or not if ($namingDirectory->search('php:env/args/t')) { echo 'Syntax OK' . PHP_EOL; exit(0); } } catch (NamingException $ne) { // do nothing, because we're NOT in configuration test mode } // initialize the SimpleXMLElement with the content XML configuration file $configuration = new Configuration(); $configuration->initFromString($doc->saveXML()); // initialize the configuration and the base directory $systemConfiguration = new AppserverNode(); $systemConfiguration->initFromConfiguration($configuration); $applicationServer->setSystemConfiguration($systemConfiguration); } catch (\Exception $e) { // render the validation errors and exit immediately echo $e . PHP_EOL; exit(0); } }
/** * Merges this configuration element with the passed configuration data. * * @param string $string The string with the XML content to initialize from * * @return \AppserverIo\Configuration\Interfaces\ConfigurationInterface The configuration created from the passed string */ public function mergeFromString($string) { // initialize a new configuration instance $configuration = new Configuration(); $configuration->initFromString($string); // merge the instance with this one $this->merge($configuration); // return this instance return $configuration; }
/** * Initialise from string * * @param string $string The string to configure from * * @return void */ public function initFromString($string) { $configuration = new Configuration(); $configuration->initFromString($string); $this->initFromConfiguration($configuration); }