public function Twig_Environment::getFilter in Translation template extractor 6.3
Same name and namespace in other branches
- 7.3 vendor/Twig/Environment.php \Twig_Environment::getFilter()
Get a filter by name.
Subclasses may override this method and load filters differently; so no list of filters is available.
Parameters
string $name The filter name:
Return value
Twig_Filter|false A Twig_Filter instance or false if the filter does not exist
File
- vendor/
Twig/ Environment.php, line 815
Class
- Twig_Environment
- Stores the Twig configuration.
Code
public function getFilter($name) {
if (!$this->extensionInitialized) {
$this
->initExtensions();
}
if (isset($this->filters[$name])) {
return $this->filters[$name];
}
foreach ($this->filters as $pattern => $filter) {
$pattern = str_replace('\\*', '(.*?)', preg_quote($pattern, '#'), $count);
if ($count) {
if (preg_match('#^' . $pattern . '$#', $name, $matches)) {
array_shift($matches);
$filter
->setArguments($matches);
return $filter;
}
}
}
foreach ($this->filterCallbacks as $callback) {
if (false !== ($filter = call_user_func($callback, $name))) {
return $filter;
}
}
return false;
}