You are here

public function Twig_Extension_Escaper::setDefaultStrategy in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/twig/twig/lib/Twig/Extension/Escaper.php \Twig_Extension_Escaper::setDefaultStrategy()

Sets the default strategy to use when not defined by the user.

The strategy can be a valid PHP callback that takes the template "filename" as an argument and returns the strategy to use.

Parameters

string|false|callable $defaultStrategy An escaping strategy:

1 call to Twig_Extension_Escaper::setDefaultStrategy()
Twig_Extension_Escaper::__construct in vendor/twig/twig/lib/Twig/Extension/Escaper.php
Constructor.

File

vendor/twig/twig/lib/Twig/Extension/Escaper.php, line 52

Class

Twig_Extension_Escaper

Code

public function setDefaultStrategy($defaultStrategy) {

  // for BC
  if (true === $defaultStrategy) {
    @trigger_error('Using "true" as the default strategy is deprecated. Use "html" instead.', E_USER_DEPRECATED);
    $defaultStrategy = 'html';
  }
  if ('filename' === $defaultStrategy) {
    $defaultStrategy = array(
      'Twig_FileExtensionEscapingStrategy',
      'guess',
    );
  }
  $this->defaultStrategy = $defaultStrategy;
}