/** * call mode handler * * @throws Exception * @return void */ public function main() { $modeSettings = $this->config->get('mode', $this->request->getMode()); if ($modeSettings === null) { throw new RuntimeException('mode `' . $this->request->getMode() . '` not applied'); } if (!isset($modeSettings['handler']) || !class_exists($modeSettings['handler'])) { throw new RuntimeException('mode `' . $this->request->getMode() . '` is invalid'); } $handler = new $modeSettings['handler']($this->config, $this->request, $modeSettings); if (!$handler instanceof AbstractModeHandler) { throw new RuntimeException('mode `' . $this->request->getMode() . '` handler `' . $modeSettings['handler'] . '` is not instance of `handler\\mode\\AbstractModeHandler`'); } $handler->handle(); }