1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace GinoPane\BlogTaxonomy\Controllers; |
4
|
|
|
|
5
|
|
|
use Flash; |
6
|
|
|
use BackendMenu; |
7
|
|
|
use Backend\Classes\Controller; |
8
|
|
|
use GinoPane\BlogTaxonomy\Plugin; |
9
|
|
|
use Backend\Behaviors\FormController; |
10
|
|
|
use Backend\Behaviors\ListController; |
11
|
|
|
use Backend\Behaviors\RelationController; |
12
|
|
|
use GinoPane\BlogTaxonomy\Models\Series as SeriesModel; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class Series |
16
|
|
|
* |
17
|
|
|
* @package GinoPane\BlogTaxonomy\Controllers |
18
|
|
|
*/ |
19
|
|
View Code Duplication |
class Series extends Controller |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* Behaviours implemented by the controller |
23
|
|
|
* |
24
|
|
|
* @var array |
25
|
|
|
*/ |
26
|
|
|
public $implement = [ |
27
|
|
|
FormController::class, |
28
|
|
|
ListController::class, |
29
|
|
|
RelationController::class |
30
|
|
|
]; |
31
|
|
|
|
32
|
|
|
public $formConfig = 'config_form.yaml'; |
33
|
|
|
public $listConfig = 'config_list.yaml'; |
34
|
|
|
public $relationConfig = 'config_relation.yaml'; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Series constructor |
38
|
|
|
*/ |
39
|
|
|
public function __construct() |
40
|
|
|
{ |
41
|
|
|
parent::__construct(); |
42
|
|
|
|
43
|
|
|
BackendMenu::setContext(Plugin::REQUIRED_PLUGIN_RAINLAB_BLOG, 'blog', 'series'); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Controller "update" action used for updating existing model records. |
48
|
|
|
* This action takes a record identifier (primary key of the model) |
49
|
|
|
* to locate the record used for sourcing the existing form values. |
50
|
|
|
* |
51
|
|
|
* @param int $recordId Record identifier |
|
|
|
|
52
|
|
|
* @param string $context Form context |
|
|
|
|
53
|
|
|
* @return void |
54
|
|
|
*/ |
55
|
|
|
public function update($recordId = null, $context = null) |
56
|
|
|
{ |
57
|
|
|
$series = SeriesModel::whereId($recordId)->first(); |
58
|
|
|
|
59
|
|
|
if ($series !== null) { |
60
|
|
|
$this->pageTitle = trans(Plugin::LOCALIZATION_KEY . 'form.series.edit_title', ['series' => $series->title]); |
61
|
|
|
} else { |
62
|
|
|
$this->pageTitle = trans(Plugin::LOCALIZATION_KEY . 'form.series.series_does_not_exist'); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
return $this->asExtension('FormController')->update($recordId, $context); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Remove multiple tags |
70
|
|
|
* |
71
|
|
|
* @return mixed |
72
|
|
|
*/ |
73
|
|
|
public function onBulkDelete() |
74
|
|
|
{ |
75
|
|
|
if ($checkedIds = (array)post('checked', [])) { |
76
|
|
|
$delete = SeriesModel::whereIn('id', $checkedIds)->delete(); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
if (empty($delete)) { |
80
|
|
|
Flash::error(e(trans(Plugin::LOCALIZATION_KEY . 'form.errors.unknown'))); |
81
|
|
|
|
82
|
|
|
return; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
Flash::success(e(trans(Plugin::LOCALIZATION_KEY . 'form.series.delete_series_success'))); |
86
|
|
|
|
87
|
|
|
return $this->listRefresh(); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.