Skip to content

Commit

Permalink
Remove getters in TwigCommands (#6133)
Browse files Browse the repository at this point in the history
  • Loading branch information
weitzman authored Oct 12, 2024
1 parent 5432b85 commit c60badf
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions src/Commands/core/TwigCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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)) {
Expand All @@ -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);
}
Expand All @@ -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]));
}
}
Expand All @@ -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,
Expand Down

0 comments on commit c60badf

Please sign in to comment.