From 792eef60edb7449de81ea45397c8ffb7fda78e3b Mon Sep 17 00:00:00 2001 From: Victor Boctor Date: Sat, 13 Jul 2019 16:38:31 -0700 Subject: [PATCH] Rename command and REST API - Rename comman from `IssueViewCommand` to `IssueViewPageCommand`. - Rename rest API to `/api/rest/pages/issues/view` --- api/rest/index.php | 1 + api/rest/restcore/issues_rest.php | 22 --------- api/rest/restcore/pages_rest.php | 48 +++++++++++++++++++ bug_view_inc.php | 2 +- ...ewCommand.php => IssueViewPageCommand.php} | 2 +- 5 files changed, 51 insertions(+), 24 deletions(-) create mode 100644 api/rest/restcore/pages_rest.php rename core/commands/{IssueViewCommand.php => IssueViewPageCommand.php} (99%) diff --git a/api/rest/index.php b/api/rest/index.php index 7d5b01bbdd..94f2eeb387 100644 --- a/api/rest/index.php +++ b/api/rest/index.php @@ -100,6 +100,7 @@ require_once( $t_restcore_dir . 'lang_rest.php' ); require_once( $t_restcore_dir . 'projects_rest.php' ); require_once( $t_restcore_dir . 'users_rest.php' ); +require_once( $t_restcore_dir . 'pages_rest.php' ); event_signal( 'EVENT_REST_API_ROUTES', array( array( 'app' => $g_app ) ) ); diff --git a/api/rest/restcore/issues_rest.php b/api/rest/restcore/issues_rest.php index 9d2dacce80..a71d7a5686 100644 --- a/api/rest/restcore/issues_rest.php +++ b/api/rest/restcore/issues_rest.php @@ -69,10 +69,6 @@ $g_app->get( '/{id}/files', 'rest_issue_files_get' ); $g_app->get( '/{id}/files/{file_id}/', 'rest_issue_files_get' ); $g_app->get( '/{id}/files/{file_id}', 'rest_issue_files_get' ); - - # View - $g_app->get( '/{id}/view/', 'rest_issue_view' ); - $g_app->get( '/{id}/view', 'rest_issue_view' ); }); /** @@ -502,24 +498,6 @@ function rest_issue_files_get( \Slim\Http\Request $p_request, \Slim\Http\Respons withJson( array( 'files' => $t_files ) ); } -/** - * Get information necessary about an issue to render an issue view page. - * - * @param \Slim\Http\Request $p_request The request. - * @param \Slim\Http\Response $p_response The response. - * @param array $p_args Arguments - * @return \Slim\Http\Response The augmented response. - */ -function rest_issue_view( \Slim\Http\Request $p_request, \Slim\Http\Response $p_response, array $p_args ) { - $t_issue_id = isset( $p_args['id'] ) ? $p_args['id'] : $p_request->getParam( 'id' ); - - $t_data = array( 'query' => array( 'id' => $t_issue_id ) ); - $t_command = new IssueViewCommand( $t_data ); - $t_result = $t_command->execute(); - - return $p_response->withStatus( HTTP_STATUS_SUCCESS )->withJson( $t_result ); -} - /** * Convert REST API base 64 files into expected format for browser file uploads. * diff --git a/api/rest/restcore/pages_rest.php b/api/rest/restcore/pages_rest.php new file mode 100644 index 0000000000..549ba9b36e --- /dev/null +++ b/api/rest/restcore/pages_rest.php @@ -0,0 +1,48 @@ +. + +/** + * A webservice interface to Mantis Bug Tracker + * + * @package MantisBT + * @copyright Copyright MantisBT Team - mantisbt-dev@lists.sourceforge.net + * @link http://www.mantisbt.org + */ + +use Mantis\Exceptions\ClientException; + +$g_app->group('/pages', function() use ( $g_app ) { + $g_app->get( '/issues/view/{id}/', 'rest_pages_issue_view' ); + $g_app->get( '/issues/view/{id}', 'rest_pages_issue_view' ); +}); + +/** + * Get information necessary about an issue to render an issue view page. + * + * @param \Slim\Http\Request $p_request The request. + * @param \Slim\Http\Response $p_response The response. + * @param array $p_args Arguments + * @return \Slim\Http\Response The augmented response. + */ +function rest_pages_issue_view( \Slim\Http\Request $p_request, \Slim\Http\Response $p_response, array $p_args ) { + $t_issue_id = isset( $p_args['id'] ) ? $p_args['id'] : $p_request->getParam( 'id' ); + + $t_data = array( 'query' => array( 'id' => $t_issue_id ) ); + $t_command = new IssueViewPageCommand( $t_data ); + $t_result = $t_command->execute(); + + return $p_response->withStatus( HTTP_STATUS_SUCCESS )->withJson( $t_result ); +} diff --git a/bug_view_inc.php b/bug_view_inc.php index a6f9eee6a0..bbe042d480 100644 --- a/bug_view_inc.php +++ b/bug_view_inc.php @@ -88,7 +88,7 @@ 'options' => array( 'force_readonly' => $t_force_readonly ) ); -$t_cmd = new IssueViewCommand( $t_data ); +$t_cmd = new IssueViewPageCommand( $t_data ); $t_result = $t_cmd->execute(); $t_issue = $t_result['issue']; diff --git a/core/commands/IssueViewCommand.php b/core/commands/IssueViewPageCommand.php similarity index 99% rename from core/commands/IssueViewCommand.php rename to core/commands/IssueViewPageCommand.php index 44c46314ea..2d39041e2c 100644 --- a/core/commands/IssueViewCommand.php +++ b/core/commands/IssueViewPageCommand.php @@ -58,7 +58,7 @@ /** * A command that returns issue information to view. */ -class IssueViewCommand extends Command { +class IssueViewPageCommand extends Command { /** * Constructor *