Skip to content

Commit f1899f4

Browse files
committed
Use an option for twig file names in cache warmer and linter
1 parent a1054ec commit f1899f4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Command/LintCommand.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,16 @@
3939
#[AsCommand(name: 'lint:twig', description: 'Lint a Twig template and outputs encountered errors')]
4040
class LintCommand extends Command
4141
{
42+
protected string|array $namePatterns;
4243
private Environment $twig;
4344
private string $format;
4445

45-
public function __construct(Environment $twig)
46+
public function __construct(Environment $twig, string|array $namePatterns = ['*.twig'])
4647
{
4748
parent::__construct();
4849

4950
$this->twig = $twig;
51+
$this->namePatterns = $namePatterns;
5052
}
5153

5254
protected function configure()
@@ -146,7 +148,7 @@ protected function findFiles(string $filename)
146148
if (is_file($filename)) {
147149
return [$filename];
148150
} elseif (is_dir($filename)) {
149-
return Finder::create()->files()->in($filename)->name('*.twig');
151+
return Finder::create()->files()->in($filename)->name($this->namePatterns);
150152
}
151153

152154
throw new RuntimeException(sprintf('File or directory "%s" is not readable.', $filename));

0 commit comments

Comments
 (0)