/**
  * Creates a string representation of this object
  *
  * @return  string
  */
 public function toString()
 {
     return sprintf("%s(%s)@{\n" . "  [config       ] %s\n" . "  [scriptlet    ] %s\n" . "  [debug        ] %s\n" . "  [arguments    ] [%s]\n" . "  [environment  ] %s\n" . "  [logLevels  ] %s\n" . "}", nameof($this), $this->name, $this->config ? strtr($this->config->toString(), ["\n" => "\n  "]) : '(none)', $this->scriptlet ? $this->scriptlet->getName() : '(none)', implode(' | ', WebDebug::namesOf($this->debug)), implode(', ', $this->arguments), \xp::stringOf($this->environment, '  '), \xp::stringOf($this->logLevels(), '  '));
 }
 /**
  * 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 IllegalStateException('Web misconfigured: Section ' . $section . ' mapped by ' . $url . ' missing');
     }
     $app = new WebApplication($application);
     $app->withScriptlet($this->readString($profile, $section, 'class', null));
     // Configure app
     $config = $this->config ? clone $this->config : new Config();
     foreach ($this->readArray($profile, $section, 'prop-base', ['{WEBROOT}/etc']) as $prop) {
         $config->append($prop);
     }
     $app->withConfig($config);
     // Determine debug level
     $flags = WebDebug::NONE;
     foreach ($this->readArray($profile, $section, 'debug', []) as $lvl) {
         $flags |= WebDebug::flagNamed($lvl);
     }
     $app->withDebug($flags);
     // Initialization arguments
     $app->withArguments($this->readArray($profile, $section, 'init-params', []));
     // Environment
     $app->withEnvironment($this->readMap($profile, $section, 'init-envs', []));
     // Filter
     foreach ($this->readArray($profile, $section, 'filters', []) as $filter) {
         $app->withFiter($filter);
     }
     // Log levels for http status codes
     $logLevels = $this->readMap($profile, $section, 'log-level', []);
     foreach ($logLevels as $httpStatusCode => $logLevel) {
         $app->withLogLevel($httpStatusCode, $logLevel);
     }
     return $app;
 }
 /**
  * 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;
 }