From 837af296f8ccc7d8fed5b0965f8bc4f9ff24f317 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Thu, 4 Jul 2024 23:35:28 -0400 Subject: [PATCH] Make adding twig non-blocking Bake is mostly interested that twig is set, and since #17628 addPlugin() will throw on duplicates. --- src/BakePlugin.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/BakePlugin.php b/src/BakePlugin.php index 5cba4765..f45aa428 100644 --- a/src/BakePlugin.php +++ b/src/BakePlugin.php @@ -21,6 +21,7 @@ use Cake\Console\CommandCollection; use Cake\Core\BasePlugin; use Cake\Core\Configure; +use Cake\Core\Exception\CakeException; use Cake\Core\Plugin; use Cake\Core\PluginApplicationInterface; use DirectoryIterator; @@ -55,7 +56,11 @@ class BakePlugin extends BasePlugin */ public function bootstrap(PluginApplicationInterface $app): void { - $app->addPlugin('Cake/TwigView'); + try { + $app->addPlugin('Cake/TwigView'); + } catch (CakeException $e) { + // Do nothing, the app or another plugin could load Twig. + } } /**