/** * Constructor * * @param array $config An array of default values. */ public function __construct($config) { $this->config = $config; ShortcodesTrait::setShortcodesClass($this); // Set up Twig environment $this->loader = new \Twig_Loader_Array([]); $this->twig = new Twig\Environment($this->loader, ['use_strict_variables' => false]); // Set up sandbox for parsing shortcodes $this->policy = new \Twig_Sandbox_SecurityPolicy(); $this->twig->addExtension(new \Twig_Extension_Sandbox($this->policy, true)); $this->policy->setAllowedTags($this->loadShortcodes()); // Modify lexer to match special shortcode syntax $lexer = new \Twig_Lexer($this->twig, array('tag_comment' => ['{#', '#}'], 'tag_block' => ['{{%', '%}}'], 'tag_variable' => ['{#', '#}'], 'interpolation' => ['#{', '}'])); $this->twig->setLexer($lexer); }
public function __construct(array $allowedTags = array(), array $allowedFilters = array(), array $allowedMethods = array(), array $allowedProperties = array()) { parent::__construct($allowedTags, $allowedFilters, $allowedMethods, $allowedProperties); $this->allowedTags = array_merge($this->allowedTags, array('if', 'for')); $this->allowedFilters = array_merge($this->allowedFilters, array('date', 'encoding', 'default')); }