response_factory = $response_factory; $this->request = $request; $this->hook_handler = $hook_handler; $this->updater = $updater; } public function run() { try { if ( $this->updater->should_plugin_be_updated() ) { $this->updater->update_plugin(); } $response = $this->response_factory->create_response( $this->request ); } catch ( Exception $e ) { $response = $this->response_factory->create_error_response( $e ); } if ( $response instanceof JSON_Response ) { $response->send_json(); } if ( $response instanceof Redirect_Response ) { $response->redirect(); } if ( $response instanceof View_Response ) { $this->hook_handler->register_hooks(); } } public static function terminate() { if ( 'prod' === self::$env ) { exit; } } }