Skip to content

Commit

Permalink
Simplify title of 'view' screen. Catch Yii2 Exception not \Exception …
Browse files Browse the repository at this point in the history
…when record cannot be deleted.
  • Loading branch information
drsdre committed Jan 22, 2018
1 parent d60d6cd commit 4edc45b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions RadCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ public function actionView( int $id ) {
$this->findModel( $id );

// Setup page title and first breadcrumb
$this->view->title = yii::t( 'app', 'View {model_object_name}',
[ 'model_object_name' => $this->getModelObjectName() ]
);
$this->view->title = $this->getModelObjectName();
$this->addBreadCrumbs( [
[ 'label' => $this->model_name . ' Overview', 'url' => [ 'index' ] ],
ArrayHelper::getValue( $this->model, $this->model_field_name ),
Expand Down Expand Up @@ -700,7 +698,7 @@ public function getModelId() {
public function deleteModel() {
try {
return $this->model->delete();
} catch ( \Exception $e ) {
} catch ( Exception $e ) {
// Build error message
if ( $e->getCode() === 23000 && preg_match( '/CONSTRAINT `(.*)` FOREIGN/', $e->getMessage(),
$matches ) === 1
Expand Down

0 comments on commit 4edc45b

Please sign in to comment.