1 <?php
 2 class TemplateRegistry extends AuraTemplateRegisry
 3 {
 4 
 5     /**
 6     * __construct
 7     *
 8     * @param mixed $path path to template directory
 9     *
10     * @return void
11     *
12     * @access public
13     */
14     public function __construct($path = null)
15     {
16         if ($path) {
17             $map = [];
18             $pathlen = strlen($path);
19             $iter = new RegexIterator(
20                 new RecursiveIteratorIterator(
21                     new RecursiveDirectoryIterator(
22                         $path
23                     )
24                 ),
25                 '/^.+\.php$/i',
26                 RecursiveRegexIterator::GET_MATCH
27             );
28 
29             foreach ($iter as $item) {
30                 $spec = $item[0];
31                 $name = trim(
32                     substr(
33                         $spec,
34                         $pathlen,
35                         -4
36                     ),
37                     '/'
38                 );
39                 $map[$name] = $spec;
40             }
41 
42             parent::__construct($map);
43         }
44     }
45 }