Skip to content

Commit

Permalink
Implement ProjectNameInvalid exception
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhicks committed Jan 15, 2012
1 parent 4657851 commit 0d0e23c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
14 changes: 14 additions & 0 deletions application/MantisBT/Exception/Project/ProjectNameInvalid.php
@@ -0,0 +1,14 @@
<?php
namespace MantisBT\Exception\Project;
use MantisBT\Exception\ExceptionAbstract;

require_api('lang_api.php');

class ProjectNameInvalid extends ExceptionAbstract {
public function __construct($projectName) {
$errorMessage = lang_get(ERROR_PROJECT_NAME_INVALID, null, false);
$errorMessage = sprintf($errorMessage, $projectName);
parent::__construct(ERROR_PROJECT_NAME_INVALID, $errorMessage, null);
$this->responseCode = 400;
}
}
7 changes: 3 additions & 4 deletions application/core/project_api.php
Expand Up @@ -29,7 +29,6 @@
* @uses constant_inc.php
* @uses custom_field_api.php
* @uses database_api.php
* @uses error_api.php
* @uses file_api.php
* @uses lang_api.php
* @uses news_api.php
Expand All @@ -41,6 +40,7 @@
*/

use MantisBT\Exception\Database\ColumnNotFound;
use MantisBT\Exception\Project\ProjectNameInvalid;
use MantisBT\Exception\Project\ProjectNameNotUnique;
use MantisBT\Exception\Project\ProjectNotFound;

Expand All @@ -50,7 +50,6 @@
require_api( 'constant_inc.php' );
require_api( 'custom_field_api.php' );
require_api( 'database_api.php' );
require_api( 'error_api.php' );
require_api( 'file_api.php' );
require_api( 'lang_api.php' );
require_api( 'news_api.php' );
Expand Down Expand Up @@ -289,7 +288,7 @@ function project_create( $p_name, $p_description, $p_status, $p_view_state = VS_
$c_inherit_global = db_prepare_bool( $p_inherit_global );

if( is_blank( $p_name ) ) {
trigger_error( ERROR_PROJECT_NAME_INVALID, ERROR );
throw new ProjectNameInvalid( '{blank}' );
}

project_ensure_name_unique( $p_name );
Expand Down Expand Up @@ -369,7 +368,7 @@ function project_update( $p_project_id, $p_name, $p_description, $p_status, $p_v
$c_inherit_global = db_prepare_bool( $p_inherit_global );

if( is_blank( $p_name ) ) {
trigger_error( ERROR_PROJECT_NAME_INVALID, ERROR );
throw new ProjectNameInvalid( '{blank}' );
}

$t_old_name = project_get_field( $p_project_id, 'name' );
Expand Down

0 comments on commit 0d0e23c

Please sign in to comment.