UIPatternsSettingsExtension.php in UI Patterns Settings 8.2
File
src/TwigExtension/UIPatternsSettingsExtension.php
View source
<?php
namespace Drupal\ui_patterns_settings\TwigExtension;
use Drupal\ui_patterns\UiPatterns;
use Drupal\ui_patterns_settings\UiPatternsSettings;
class UIPatternsSettingsExtension extends \Twig_Extension {
public function getName() {
return 'ui_patterns_settings';
}
public function getFunctions() {
return [
new \Twig_SimpleFunction('pattern_configuration', [
$this,
'patternConfiguration',
]),
];
}
public function patternConfiguration($pattern_id, $variant_id, $config_name) {
$definition = UiPatterns::getPatternDefinition($pattern_id);
if ($definition !== NULL) {
$configuration = UiPatternsSettings::getPatternConfiguration($definition, $variant_id);
return isset($configuration[$config_name]) ? $configuration[$config_name] : NULL;
}
}
}