本文整理汇总了PHP中Twig_Environment::getShortcodeFilter方法的典型用法代码示例。如果您正苦于以下问题:PHP Twig_Environment::getShortcodeFilter方法的具体用法?PHP Twig_Environment::getShortcodeFilter怎么用?PHP Twig_Environment::getShortcodeFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Twig_Environment
的用法示例。
在下文中一共展示了Twig_Environment::getShortcodeFilter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filterShortcode
/**
* A filter function for shortcode filters
*
* @param string $name The name of the shortcode filter to be
* applied.
* @param string $content The content to be filtered.
* @param mixed $context The Twig context
* @param mixed $environment The Twig environment
*
* @return string The filtered content (here a hash); use
* $this->normalize() to replace the hash
* with the filtered content.
*/
protected function filterShortcode($name, $content, $context = null, $environment = null)
{
$output = $content;
$extra = [$name, $this];
$filters = $this->twig->getShortcodeFilter($name);
foreach ($filters as $filter) {
$arguments = [$output];
if ($filter->needsEnvironment()) {
$arguments[] = $environment;
}
if ($filter->needsContext()) {
$arguments[] = $context;
}
$arguments = array_merge($arguments, $filter->getArguments(), $extra);
$output = call_user_func_array($filter->getCallable(), $arguments);
if (!$output) {
break;
}
}
// Replace shortcode with a hash to be replaced later
return $this->hash($output);
}