Skip to content

Commit

Permalink
Rename command and REST API
Browse files Browse the repository at this point in the history
- Rename comman from `IssueViewCommand` to `IssueViewPageCommand`.
- Rename rest API to `/api/rest/pages/issues/view`
  • Loading branch information
vboctor committed Aug 25, 2019
1 parent 08abf7f commit 792eef6
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 24 deletions.
1 change: 1 addition & 0 deletions api/rest/index.php
Expand Up @@ -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 ) ) );

Expand Down
22 changes: 0 additions & 22 deletions api/rest/restcore/issues_rest.php
Expand Up @@ -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' );
});

/**
Expand Down Expand Up @@ -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.
*
Expand Down
48 changes: 48 additions & 0 deletions api/rest/restcore/pages_rest.php
@@ -0,0 +1,48 @@
<?php
# MantisBT - A PHP based bugtracking system

# MantisBT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# MantisBT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MantisBT. If not, see <http://www.gnu.org/licenses/>.

/**
* 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 );
}
2 changes: 1 addition & 1 deletion bug_view_inc.php
Expand Up @@ -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'];
Expand Down
Expand Up @@ -58,7 +58,7 @@
/**
* A command that returns issue information to view.
*/
class IssueViewCommand extends Command {
class IssueViewPageCommand extends Command {
/**
* Constructor
*
Expand Down

0 comments on commit 792eef6

Please sign in to comment.