public function printExtensions()
 {
     if ($this->descriptor->file()->get("extension")) {
         $printer = new Printer($this->context->openForInsert("autoload.php", "extension_scope:registry"), "`");
         foreach ($this->descriptor->file()->get("extension") as $ext) {
             $this->printExtension($printer, $ext);
         }
     }
 }
Exemple #2
0
 public static function execute($descriptor, GeneratorContext $context)
 {
     foreach (self::$data as $block) {
         $regex = sprintf("/%s/", $block['match']);
         if (preg_match($regex, $descriptor->getName(), $match)) {
             $file_name = $block['file'];
             $insertion_point = $block['insertion_point'];
             $count = count($match);
             for ($i = 0; $i < $count; $i++) {
                 $file_name = str_replace("\${$i}", $match[0], $file_name);
                 $insertion_point = str_replace("\${$i}", $match[0], $insertion_point);
             }
             if ($context->hasOpened($file_name)) {
                 $printer = new Printer($context->openForInsert($file_name, $insertion_point), "`");
                 $lines = preg_split("/\r?\n/", $block['insertion']);
                 foreach ($lines as $line) {
                     $printer->put($line . PHP_EOL);
                 }
             }
         }
     }
 }