Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#5971] twig compile - add optional searchpaths argument #5972

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 17 additions & 11 deletions src/Commands/core/TwigCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,26 @@ public function unused($searchpaths): RowsOfFields
* Compile all Twig template(s).
*/
#[CLI\Command(name: self::COMPILE, aliases: ['twigc', 'twig-compile'])]
public function twigCompile(): void
#[CLI\Argument(name: 'searchpaths', description: 'Optional comma delimited list of paths to recursively search')]
public function twigCompile($searchpaths = null): void
{
$searchpaths = [];
require_once DRUSH_DRUPAL_CORE . "/themes/engines/twig/twig.engine";
// Scan all enabled modules and themes.
$modules = array_keys($this->getModuleHandler()->getModuleList());
foreach ($modules as $module) {
$searchpaths[] = $this->extensionList->getPath($module);
}
if(!$searchpaths) {
require_once DRUSH_DRUPAL_CORE . "/themes/engines/twig/twig.engine";
// Scan all enabled modules and themes.
$modules = array_keys($this->getModuleHandler()->getModuleList());
foreach ($modules as $module) {
$searchpaths[] = $this->extensionList->getPath($module);
}

$themes = \Drupal::service('theme_handler')->listInfo();
foreach ($themes as $name => $theme) {
$searchpaths[] = $theme->getPath();
$themes = \Drupal::service('theme_handler')->listInfo();
foreach ($themes as $name => $theme) {
$searchpaths[] = $theme->getPath();
}
}
else {
$searchpaths = StringUtils::csvToArray($searchpaths);
}


$files = Finder::create()
->files()
Expand Down