ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Twig_Util_DeprecationCollector Class Reference
+ Collaboration diagram for Twig_Util_DeprecationCollector:

Public Member Functions

 __construct (Twig_Environment $twig)
 
 collectDir ($dir, $ext='.twig')
 Returns deprecations for templates contained in a directory. More...
 
 collect (Traversable $iterator)
 Returns deprecations for passed templates. More...
 
 errorHandler ($type, $msg)
 

Private Attributes

 $twig
 
 $deprecations
 

Detailed Description

Author
Fabien Potencier fabie.nosp@m.n@sy.nosp@m.mfony.nosp@m..com

@final

Definition at line 17 of file DeprecationCollector.php.

Constructor & Destructor Documentation

◆ __construct()

Twig_Util_DeprecationCollector::__construct ( Twig_Environment  $twig)

Definition at line 22 of file DeprecationCollector.php.

23 {
24 $this->twig = $twig;
25 }

References $twig.

Member Function Documentation

◆ collect()

Twig_Util_DeprecationCollector::collect ( Traversable  $iterator)

Returns deprecations for passed templates.

Parameters
Traversable$iteratorAn iterator of templates (where keys are template names and values the contents of the template)
Returns
array An array of deprecations

Definition at line 53 of file DeprecationCollector.php.

54 {
55 $this->deprecations = array();
56
57 set_error_handler(array($this, 'errorHandler'));
58
59 foreach ($iterator as $name => $contents) {
60 try {
61 $this->twig->parse($this->twig->tokenize(new Twig_Source($contents, $name)));
62 } catch (Twig_Error_Syntax $e) {
63 // ignore templates containing syntax errors
64 }
65 }
66
67 restore_error_handler();
68
70 $this->deprecations = array();
71
72 return $deprecations;
73 }
Exception thrown when a syntax error occurs during lexing or parsing of a template.
Definition: Syntax.php:19
Holds information about a non-compiled Twig template.
Definition: Source.php:20

References $deprecations, and $name.

Referenced by collectDir().

+ Here is the caller graph for this function:

◆ collectDir()

Twig_Util_DeprecationCollector::collectDir (   $dir,
  $ext = '.twig' 
)

Returns deprecations for templates contained in a directory.

Parameters
string$dirA directory where templates are stored
string$extLimit the loaded templates by extension
Returns
array An array of deprecations

Definition at line 35 of file DeprecationCollector.php.

36 {
37 $iterator = new RegexIterator(
38 new RecursiveIteratorIterator(
39 new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::LEAVES_ONLY
40 ), '{'.preg_quote($ext).'$}'
41 );
42
43 return $this->collect(new Twig_Util_TemplateDirIterator($iterator));
44 }
collect(Traversable $iterator)
Returns deprecations for passed templates.

References collect().

+ Here is the call graph for this function:

◆ errorHandler()

Twig_Util_DeprecationCollector::errorHandler (   $type,
  $msg 
)

Definition at line 78 of file DeprecationCollector.php.

79 {
80 if (E_USER_DEPRECATED === $type) {
81 $this->deprecations[] = $msg;
82 }
83 }
$type

References $type.

Field Documentation

◆ $deprecations

Twig_Util_DeprecationCollector::$deprecations
private

Definition at line 20 of file DeprecationCollector.php.

Referenced by collect().

◆ $twig

Twig_Util_DeprecationCollector::$twig
private

Definition at line 19 of file DeprecationCollector.php.

Referenced by __construct().


The documentation for this class was generated from the following file: