Skip to content

Commit

Permalink
Wrap addPlugin() call in has() check.
Browse files Browse the repository at this point in the history
Cake 5.1 throws exception for duplicate plugin loading and this avoids
exception if the TwigView plugin is already loaded from the application.
  • Loading branch information
ADmad committed Apr 18, 2024
1 parent 2a30ba2 commit 5d94a2c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/BakePlugin.php
Expand Up @@ -55,7 +55,9 @@ class BakePlugin extends BasePlugin
*/
public function bootstrap(PluginApplicationInterface $app): void
{
$app->addPlugin('Cake/TwigView');
if (!$app->getPlugins()->has('Cake/TwigView')) {

Check failure on line 58 in src/BakePlugin.php

View workflow job for this annotation

GitHub Actions / cs-stan / Coding Standard & Static Analysis

Call to an undefined method Cake\Core\PluginApplicationInterface::getPlugins().

Check failure on line 58 in src/BakePlugin.php

View workflow job for this annotation

GitHub Actions / cs-stan / Coding Standard & Static Analysis

UndefinedInterfaceMethod

src/BakePlugin.php:58:20: UndefinedInterfaceMethod: Method Cake\Core\PluginApplicationInterface::getPlugins does not exist (see https://psalm.dev/181)
$app->addPlugin('Cake/TwigView');
}
}

/**
Expand Down

0 comments on commit 5d94a2c

Please sign in to comment.