Harden the debugging of Twig filters and functions
Removing the environment and context arguments is now based on Twig metadata rather than on some wild guessing which might go wrong.
This commit is contained in:
parent
aa04f35092
commit
63a8aff2c8
@ -159,14 +159,20 @@ EOF
|
|||||||
throw new \UnexpectedValueException('Unsupported callback type');
|
throw new \UnexpectedValueException('Unsupported callback type');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$args = $refl->getParameters();
|
||||||
|
|
||||||
// filter out context/environment args
|
// filter out context/environment args
|
||||||
$args = array_filter($refl->getParameters(), function ($param) use ($entity) {
|
if ($entity->needsEnvironment()) {
|
||||||
if ($entity->needsContext() && $param->getName() === 'context') {
|
array_shift($args);
|
||||||
return false;
|
}
|
||||||
|
if ($entity->needsContext()) {
|
||||||
|
array_shift($args);
|
||||||
}
|
}
|
||||||
|
|
||||||
return !$param->getClass() || $param->getClass()->getName() !== 'Twig_Environment';
|
if ($type === 'filters') {
|
||||||
});
|
// remove the value the filter is applied on
|
||||||
|
array_shift($args);
|
||||||
|
}
|
||||||
|
|
||||||
// format args
|
// format args
|
||||||
$args = array_map(function ($param) {
|
$args = array_map(function ($param) {
|
||||||
@ -177,11 +183,6 @@ EOF
|
|||||||
return $param->getName();
|
return $param->getName();
|
||||||
}, $args);
|
}, $args);
|
||||||
|
|
||||||
if ($type === 'filters') {
|
|
||||||
// remove the value the filter is applied on
|
|
||||||
array_shift($args);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $args;
|
return $args;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user