コード例 #1
0
 public function testSetAndGetOptions()
 {
     $extension = new TwigExtension();
     $options = new TwigOptionsDefinition();
     $options->set('is_safe', ['html']);
     $extension->setOptions($options);
     $this->assertSame(['is_safe' => ['html']], $extension->getOptions()->toArray());
 }
コード例 #2
0
 public function testSetAndGetOptions()
 {
     $options = new TwigOptionsDefinition();
     $options->set('needs_environment', true);
     $options->set('is_safe', ['html']);
     $more = new TwigOptionsDefinition();
     $more->set('is_safe', []);
     $options->merge($more, false);
     $this->assertSame(['needs_environment' => true, 'is_safe' => ['html']], $options->toArray());
     $options->merge($more);
     $this->assertSame(['needs_environment' => true, 'is_safe' => []], $options->toArray());
 }
コード例 #3
0
ファイル: TwigExtension.php プロジェクト: scr-be/wonka-bundle
 /**
  * Sets the option that allows for HTML to be returned from the extension function.
  *
  * @param bool $enable
  *
  * @return $this
  */
 public function addOptionHtmlSafe($enable = true)
 {
     $this->options->set('is_safe', $enable ? ['html'] : []);
     return $this;
 }