Skip to content

Commit

Permalink
Merge pull request #983 from cakephp/plugin-add
Browse files Browse the repository at this point in the history
Wrap addPlugin() call in has() check.
  • Loading branch information
markstory authored Jul 2, 2024
2 parents 94851a5 + c3cf5c0 commit 97e6077
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .phive/phars.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpstan" version="1.10.56" installed="1.10.56" location="./tools/phpstan" copy="false"/>
<phar name="psalm" version="5.20.0" installed="5.20.0" location="./tools/psalm" copy="false"/>
<phar name="phpstan" version="1.11.6" installed="1.11.6" location="./tools/phpstan" copy="false"/>
<phar name="psalm" version="5.25.0" installed="5.25.0" location="./tools/psalm" copy="false"/>
</phive>
3 changes: 2 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ includes:

parameters:
level: 6
checkMissingIterableValueType: false
paths:
- src/
bootstrapFiles:
- tests/bootstrap.php
ignoreErrors:
- identifier: missingType.iterableValue
7 changes: 6 additions & 1 deletion src/BakePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\Core\PluginApplicationInterface;
use Cake\Http\BaseApplication;
use DirectoryIterator;
use ReflectionClass;
use ReflectionException;
Expand Down Expand Up @@ -55,7 +56,11 @@ class BakePlugin extends BasePlugin
*/
public function bootstrap(PluginApplicationInterface $app): void
{
$app->addPlugin('Cake/TwigView');
assert($app instanceof BaseApplication);

if (!$app->getPlugins()->has('Cake/TwigView')) {
$app->addPlugin('Cake/TwigView');
}
}

/**
Expand Down

0 comments on commit 97e6077

Please sign in to comment.