diff --git a/composer.json b/composer.json index 126e27142..38cea4726 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,7 @@ "phpunit/phpunit": "^8.0|^9.0", "fzaninotto/faker": "~1.9", "squizlabs/php_codesniffer": "3.*", - "jakub-onderka/php-parallel-lint": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.0", "meyfa/phpunit-assert-gd": "^2.0.0", "dms/phpunit-arraysubset-asserts": "^0.1.0" }, diff --git a/modules/backend/behaviors/FormController.php b/modules/backend/behaviors/FormController.php index 175571f54..b918a89c3 100644 --- a/modules/backend/behaviors/FormController.php +++ b/modules/backend/behaviors/FormController.php @@ -474,7 +474,7 @@ class FormController extends ControllerBehavior } if (post('redirect', true)) { - $redirectUrl = $this->getRedirectUrl($context); + $redirectUrl = $this->controller->formGetRedirectUrl($context, $model); } if ($model && $redirectUrl) { @@ -493,13 +493,15 @@ class FormController extends ControllerBehavior } /** - * Internal method that returns a redirect URL from the config based on - * supplied context. Otherwise the default redirect is used. + * Returns a redirect URL from the config based on supplied context. + * Otherwise the default redirect is used. Relative URLs are treated as + * backend URLs. * * @param string $context Redirect context, eg: create, update, delete. + * @param Model $model The active model. * @return string */ - protected function getRedirectUrl($context = null) + public function formGetRedirectUrl($context = null, $model = null) { $redirectContext = explode('-', $context, 2)[0]; $redirectSource = ends_with($context, '-close') ? 'redirectClose' : 'redirect'; diff --git a/modules/backend/behaviors/ImportExportController.php b/modules/backend/behaviors/ImportExportController.php index 88e063ce7..950234362 100644 --- a/modules/backend/behaviors/ImportExportController.php +++ b/modules/backend/behaviors/ImportExportController.php @@ -619,6 +619,7 @@ class ImportExportController extends ControllerBehavior * Prepare CSV */ $csv = CsvWriter::createFromFileObject(new SplTempFileObject); + $csv->setOutputBOM(CsvWriter::BOM_UTF8); $csv->setDelimiter($options['delimiter']); $csv->setEnclosure($options['enclosure']); $csv->setEscape($options['escape']); diff --git a/modules/backend/behaviors/ListController.php b/modules/backend/behaviors/ListController.php index 06709017d..0a14fff18 100644 --- a/modules/backend/behaviors/ListController.php +++ b/modules/backend/behaviors/ListController.php @@ -42,17 +42,17 @@ class ListController extends ControllerBehavior protected $listConfig = []; /** - * @var \Backend\Classes\WidgetBase Reference to the list widget object. + * @var \Backend\Classes\WidgetBase[] Reference to the list widget object. */ protected $listWidgets = []; /** - * @var \Backend\Classes\WidgetBase Reference to the toolbar widget objects. + * @var \Backend\Classes\WidgetBase[] Reference to the toolbar widget objects. */ protected $toolbarWidgets = []; /** - * @var \Backend\Classes\WidgetBase Reference to the filter widget objects. + * @var \Backend\Classes\WidgetBase[] Reference to the filter widget objects. */ protected $filterWidgets = []; @@ -114,7 +114,7 @@ class ListController extends ControllerBehavior /** * Prepare the widgets used by this action - * @return void + * @return \Backend\Widgets\Lists */ public function makeList($definition = null) { @@ -165,7 +165,7 @@ class ListController extends ControllerBehavior /* * List Widget with extensibility */ - $widget = $this->makeWidget('Backend\Widgets\Lists', $columnConfig); + $widget = $this->makeWidget(\Backend\Widgets\Lists::class, $columnConfig); $widget->bindEvent('list.extendColumns', function () use ($widget) { $this->controller->listExtendColumns($widget); @@ -203,7 +203,7 @@ class ListController extends ControllerBehavior if (isset($listConfig->toolbar)) { $toolbarConfig = $this->makeConfig($listConfig->toolbar); $toolbarConfig->alias = $widget->alias . 'Toolbar'; - $toolbarWidget = $this->makeWidget('Backend\Widgets\Toolbar', $toolbarConfig); + $toolbarWidget = $this->makeWidget(\Backend\Widgets\Toolbar::class, $toolbarConfig); $toolbarWidget->bindToController(); $toolbarWidget->cssClasses[] = 'list-header'; @@ -236,7 +236,7 @@ class ListController extends ControllerBehavior $filterConfig = $this->makeConfig($listConfig->filter); $filterConfig->alias = $widget->alias . 'Filter'; - $filterWidget = $this->makeWidget('Backend\Widgets\Filter', $filterConfig); + $filterWidget = $this->makeWidget(\Backend\Widgets\Filter::class, $filterConfig); $filterWidget->bindToController(); /* @@ -286,6 +286,7 @@ class ListController extends ControllerBehavior /** * Bulk delete records. * @return void + * @throws \October\Rain\Exception\ApplicationException when the parent definition is missing. */ public function index_onDelete() { @@ -353,6 +354,7 @@ class ListController extends ControllerBehavior * Renders the widget collection. * @param string $definition Optional list definition. * @return string Rendered HTML for the list. + * @throws \October\Rain\Exception\ApplicationException when there are no list widgets set. */ public function listRender($definition = null) { @@ -455,7 +457,7 @@ class ListController extends ControllerBehavior /** * Called after the list columns are defined. - * @param \Backend\Widgets\List $host The hosting list widget + * @param \Backend\Widgets\Lists $host The hosting list widget * @return void */ public function listExtendColumns($host) @@ -473,8 +475,9 @@ class ListController extends ControllerBehavior /** * Controller override: Extend supplied model - * @param Model $model - * @return Model + * @param \October\Rain\Database\Model $model + * @param string|null $definition + * @return \October\Rain\Database\Model */ public function listExtendModel($model, $definition = null) { @@ -485,6 +488,7 @@ class ListController extends ControllerBehavior * Controller override: Extend the query used for populating the list * before the default query is processed. * @param \October\Rain\Database\Builder $query + * @param string|null $definition */ public function listExtendQueryBefore($query, $definition = null) { @@ -494,6 +498,7 @@ class ListController extends ControllerBehavior * Controller override: Extend the query used for populating the list * after the default query is processed. * @param \October\Rain\Database\Builder $query + * @param string|null $definition */ public function listExtendQuery($query, $definition = null) { @@ -502,7 +507,8 @@ class ListController extends ControllerBehavior /** * Controller override: Extend the records used for populating the list * after the query is processed. - * @param Illuminate\Contracts\Pagination\LengthAwarePaginator|Illuminate\Database\Eloquent\Collection $records + * @param \Illuminate\Contracts\Pagination\LengthAwarePaginator|\Illuminate\Database\Eloquent\Collection $records + * @param string|null $definition */ public function listExtendRecords($records, $definition = null) { @@ -520,9 +526,9 @@ class ListController extends ControllerBehavior /** * Returns a CSS class name for a list row (