/** * Creates a web application object from a given configuration section * * @param string profile * @param string application app name * @param string url * @return xp.scriptlet.WebApplication * @throws lang.IllegalStateException if the web is misconfigured */ protected function configuredApp($profile, $application, $url) { $section = 'app::' . $application; if (!$this->prop->hasSection($section)) { throw new \lang\IllegalStateException('Web misconfigured: Section ' . $section . ' mapped by ' . $url . ' missing'); } $app = new WebApplication($application); $app->setScriptlet($this->readString($profile, $section, 'class', '')); // Configuration base $app->setConfig($this->readString($profile, $section, 'prop-base', '{WEBROOT}/etc')); // Determine debug level $flags = WebDebug::NONE; foreach ($this->readArray($profile, $section, 'debug', array()) as $lvl) { $flags |= WebDebug::flagNamed($lvl); } $app->setDebug($flags); // Initialization arguments $app->setArguments($this->readArray($profile, $section, 'init-params', array())); // Environment $app->setEnvironment($this->readHash($profile, $section, 'init-envs', new Hashmap())->toArray()); return $app; }