From c60badffda926de5bf08f12dfa5c117cf3919454 Mon Sep 17 00:00:00 2001 From: Moshe Weitzman Date: Sat, 12 Oct 2024 04:49:28 -0400 Subject: [PATCH] Remove getters in TwigCommands (#6133) --- src/Commands/core/TwigCommands.php | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/src/Commands/core/TwigCommands.php b/src/Commands/core/TwigCommands.php index 3c215cb2a1..001ff11ddb 100644 --- a/src/Commands/core/TwigCommands.php +++ b/src/Commands/core/TwigCommands.php @@ -36,16 +36,6 @@ public function __construct( ) { } - public function getTwig(): TwigEnvironment - { - return $this->twig; - } - - public function getModuleHandler(): ModuleHandlerInterface - { - return $this->moduleHandler; - } - /** * Find potentially unused Twig templates. * @@ -73,8 +63,8 @@ public function unused($searchpaths): RowsOfFields // Check to see if a compiled equivalent exists in PHPStorage foreach ($files as $file) { $relative = Path::makeRelative($file->getRealPath(), Drush::bootstrapManager()->getRoot()); - $mainCls = $this->getTwig()->getTemplateClass($relative); - $cache = $this->getTwig()->getCache(); + $mainCls = $this->twig->getTemplateClass($relative); + $cache = $this->twig->getCache(); if ($cache) { $key = $cache->generateKey($relative, $mainCls); if (!$phpstorage->exists($key)) { @@ -100,7 +90,7 @@ public function twigCompile(): void $searchpaths = []; require_once DRUSH_DRUPAL_CORE . "/themes/engines/twig/twig.engine"; // Scan all enabled modules and themes. - $modules = array_keys($this->getModuleHandler()->getModuleList()); + $modules = array_keys($this->moduleHandler->getModuleList()); foreach ($modules as $module) { $searchpaths[] = $this->extensionList->getPath($module); } @@ -118,7 +108,7 @@ public function twigCompile(): void foreach ($files as $file) { $relative = Path::makeRelative($file->getRealPath(), Drush::bootstrapManager()->getRoot()); // Loading the template ensures the compiled template is cached. - $this->getTwig()->load($relative); + $this->twig->load($relative); $this->logger()->success(dt('Compiled twig template !path', ['!path' => $relative])); } } @@ -133,10 +123,6 @@ public function twigCompile(): void #[CLI\Version(version: '12.1')] public function twigDebug(string $mode): void { - // @todo Remove this condition once Drush drops support for Drupal 10.0. - if (version_compare(\Drupal::VERSION, '10.1.0') < 0) { - throw new \Exception('Twig debug command requires Drupal 10.1.0 and above.'); - } $mode = match ($mode) { 'on' => true, 'off' => false,