diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a55000..52d7b97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,7 +59,7 @@ jobs: php-version: '8.1' extensions: mbstring, intl coverage: none - tools: vimeo/psalm:4.23, phpstan:1.7, cs2pr + tools: vimeo/psalm:4, phpstan:1.9, cs2pr - name: Composer Install run: composer require --dev cakephp/cakephp-codesniffer:5.x-dev diff --git a/composer.json b/composer.json index 0a9d792..6a8ca25 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,11 @@ "wiki": "http://cakephp.nu/cakephp-crud/", "irc": "irc://irc.freenode.org/friendsofcake" }, + "prefer-stable": true, "config": { - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } } } diff --git a/docs/requirements.txt b/docs/requirements.txt index 2734cd2..e9f5e9f 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,7 +1,7 @@ alabaster==0.7.12 Babel==2.9.1 cakephp-theme==1.1.3 -certifi==2019.11.28 +certifi==2022.12.7 chardet==3.0.4 docutils==0.15.2 idna==2.8 diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index b028a22..f58831e 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,22 +1,7 @@ parameters: ignoreErrors: - - message: "#^Access to an undefined property object\\:\\:\\$element\\.$#" - count: 1 - path: src/Listener/ViewListener.php - - - - message: "#^Access to an undefined property object\\:\\:\\$query\\.$#" - count: 4 - path: src/Listener/ViewListener.php - - - - message: "#^Access to an undefined property object\\:\\:\\$type\\.$#" - count: 1 - path: src/Listener/ViewListener.php - - - - message: "#^Cannot unset offset mixed on array\\.$#" + message: "#^Cannot unset offset mixed on array\\{\\}\\.$#" count: 2 path: src/Listener/ViewListener.php diff --git a/phpstan.neon b/phpstan.neon index aba1800..3b09bdc 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -4,6 +4,7 @@ includes: parameters: level: 7 checkMissingIterableValueType: false + checkGenericClassInNonGenericObjectType: false paths: - src universalObjectCratesClasses: diff --git a/src/Listener/Traits/FormTypeTrait.php b/src/Listener/Traits/FormTypeTrait.php index 842d31a..d2e84a7 100644 --- a/src/Listener/Traits/FormTypeTrait.php +++ b/src/Listener/Traits/FormTypeTrait.php @@ -133,7 +133,11 @@ protected function _getDefaultExtraLeftButtons(): array $action = $this->_action(); if ($action instanceof EditAction) { $blacklist = $action->getConfig('scaffold.actions_blacklist', []); - if (!in_array('delete', $blacklist, true)) { + if ( + !in_array('delete', $blacklist, true) && + $this->_crud()->isActionMapped('delete') && + $this->_crud()->action('delete')->enabled() + ) { $buttons[] = [ 'title' => __d('crud', 'Delete'), 'url' => ['action' => 'delete'], diff --git a/src/Listener/ViewListener.php b/src/Listener/ViewListener.php index 7a7ca24..6bfb475 100644 --- a/src/Listener/ViewListener.php +++ b/src/Listener/ViewListener.php @@ -504,7 +504,10 @@ protected function _getAllowedActions(): array $blacklist = (array)$this->_action()->getConfig('scaffold.actions_blacklist'); $blacklist = array_combine($blacklist, $blacklist); foreach ($this->_crud()->getConfig('actions') as $action => $config) { - if ($config['className'] === 'Crud.Lookup') { + if ( + $config['className'] === 'Crud.Lookup' || + !$this->_crud()->action($action)->enabled() + ) { $blacklist[$action] = $action; } } diff --git a/webroot/js/local.js b/webroot/js/local.js index ebe5b89..319c379 100644 --- a/webroot/js/local.js +++ b/webroot/js/local.js @@ -47,7 +47,7 @@ var CrudView = { query[$ele.data('filter-field') || $ele.attr('name')] = params.term; if ($ele.data('dependent-on') && $('#' + $ele.data('dependent-on')).val()) { - data[$ele.data('dependent-on-field')] = $('#' + $ele.data('dependent-on')).val(); + query[$ele.data('dependent-on-field')] = $('#' + $ele.data('dependent-on')).val(); } return query;