* @return array
* Returns the options of this handler/plugin.
*/
- protected function defineOptions() { return []; }
+ protected function defineOptions() {
+ return [];
+ }
/**
* Fills up the options of the plugin with defaults.
/**
* {@inheritdoc}
*/
- public function validateOptionsForm(&$form, FormStateInterface $form_state) { }
+ public function validateOptionsForm(&$form, FormStateInterface $form_state) {}
/**
* {@inheritdoc}
*/
- public function submitOptionsForm(&$form, FormStateInterface $form_state) { }
+ public function submitOptionsForm(&$form, FormStateInterface $form_state) {}
/**
* {@inheritdoc}
*/
- public function query() { }
+ public function query() {}
/**
* {@inheritdoc}
/**
* {@inheritdoc}
*/
- public function validate() { return []; }
+ public function validate() {
+ return [];
+ }
/**
* {@inheritdoc}
foreach ($tokens as $token => $replacement) {
// Twig wants a token replacement array stripped of curly-brackets.
// Some Views tokens come with curly-braces, others do not.
- //@todo: https://www.drupal.org/node/2544392
+ // @todo: https://www.drupal.org/node/2544392
if (strpos($token, '{{') !== FALSE) {
// Twig wants a token replacement array stripped of curly-brackets.
$token = trim(str_replace(['{{', '}}'], '', $token));
// We need to validate tokens are valid Twig variables. Twig uses the
// same variable naming rules as PHP.
// @see http://php.net/manual/language.variables.basics.php
- assert('preg_match(\'/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/\', $token) === 1', 'Tokens need to be valid Twig variables.');
+ assert(preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $token) === 1, 'Tokens need to be valid Twig variables.');
$twig_tokens[$token] = $replacement;
}
else {
$parts = explode('.', $token);
$top = array_shift($parts);
- assert('preg_match(\'/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/\', $top) === 1', 'Tokens need to be valid Twig variables.');
+ assert(preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $top) === 1, 'Tokens need to be valid Twig variables.');
$token_array = [array_pop($parts) => $replacement];
foreach (array_reverse($parts) as $key) {
// The key could also be numeric (array index) so allow that.
- assert('is_numeric($key) || (preg_match(\'/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/\', $key) === 1)', 'Tokens need to be valid Twig variables.');
+ assert(is_numeric($key) || preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $key) === 1, 'Tokens need to be valid Twig variables.');
$token_array = [$key => $token_array];
}
if (!isset($twig_tokens[$top])) {
'#post_render' => [
function ($children, $elements) {
return Xss::filterAdmin($children);
- }
+ },
],
];