-
Notifications
You must be signed in to change notification settings - Fork 394
Conversation
PHPCS fix.
PHPCS fix.
src/Robo/Blt.php
Outdated
$twig = new Environment(new FilesystemLoader()); | ||
|
||
// Get any custom defined Twig filters to be ignored by linter. | ||
$twig_filters = (array) $this->getConfig()->get('validate.twig.filters'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, do you see an instance in which we will need to use this array? I see that it is currently empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If developers add Twig functions or filters to their custom modules and use them in their twig templates, they'll need to add them to their project.yml, otherwise they'll fail validation. I suppose the empty array can be left out of build.yml, and the ability to add functions and filters documented somewhere instead?
src/Robo/Blt.php
Outdated
// Get any custom defined Twig filters to be ignored by linter. | ||
$twig_filters = (array) $this->getConfig()->get('validate.twig.filters'); | ||
// Add Twig filters from Drupal TwigExtension to be ignored. | ||
// @todo Find a way so that this list doesn't need to be maintained. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think this is where I started to lose the thread. I wanted to somehow load Drupal\Core\Template\TwigExtension
into the $twig
environment, but that led down a rabbit hole of determining how to get the right services to inject into TwigExtension
.
src/Robo/Blt.php
Outdated
$twig_filters = (array) $this->getConfig()->get('validate.twig.filters'); | ||
// Add Twig filters from Drupal TwigExtension to be ignored. | ||
// @todo Find a way so that this list doesn't need to be maintained. | ||
$drupal_filters = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nobody loves regular expressions, but you could load the text content of docroot/core/lib/Drupal/Core/Template/TwigExtension.php
and then use a regex to identify the functions and filters:
$matches_count = preg_match_all("#new \\Twig_SimpleFunction\('([^']+)',#", file_get_contents('docroot/core/lib/Drupal/Core/Template/TwigExtension.php'), $matches);
array_shift($matches);
$functions = $matches;
$matches_count = preg_match_all("#new \\Twig_SimpleFilter\('([^']+)',#", file_get_contents('docroot/core/lib/Drupal/Core/Template/TwigExtension.php'), $matches);
array_shift($matches);
$filters = $matches;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that's not a bad idea. I'll try to update the PR soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the updates, and tested.
I'm not sure why Travis is failing, though.
…sion instead of hardcoding lists.
I'm restarting the test to be sure, but it looks like something about this is causing the pre-commit validators to not run correctly. |
@danepowell I think you're right. I haven't had much luck reproducing locally, but I'll look into it more. |
$filesets[$fileset_id] = $fileset_manager->filterFilesByFileset($files, $fileset); | ||
} | ||
|
||
$command = "'$bin/blt' 'validate:twig:files' '%s'"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't you removing the validate:twig:files
command above? Doesn't seem like it makes sense to call it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validate:twig:files
gets added in src/Robo/Blt.php
line 157.
Created new PR against 9.1 #2151 |
Fixes #1543.
Changes proposed: