Advertisement
Guest User

Map Creator

a guest
Jun 20th, 2016
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.15 KB | None | 0 0
  1. <?php
  2. class MapCreator {
  3.     private $pastas = array();
  4.     private $classes  = array();
  5.  
  6.     function __construct(array $pastas){
  7.         $this->pastas = $pastas;
  8.     }
  9.  
  10.     private function getClassFromPath(array $paths){
  11.         foreach ($paths as $key => $path) {    
  12.            
  13.             $files = scandir($path);
  14.             foreach ($files as $key => $file) {
  15.                 if($file != "." && $file != ".."){
  16.                     if(is_file($path.$file)){
  17.                         if(end(explode(".",$file)) == "php"){
  18.                             $classe = new stdClass;
  19.                             $classe->nome = explode(".",$file)[0];
  20.                             $classe->caminho = $path.$file;
  21.                             $this->classes[] = $classe;
  22.                         }
  23.                     }
  24.                     else if(is_dir($path.$file)){
  25.                         $this->getClassFromPath(array($path.$file."/"));
  26.                     }
  27.                 }
  28.             }
  29.         }
  30.     }
  31.     public function getMap(){
  32.         $this->getClassFromPath($this->pastas);
  33.         $content = "<?php\n";
  34.         foreach ($this->classes as $key => $classe) {
  35.             $content .="AdiantiCoreLoader::setClassPath('{$classe->nome}','{$classe->caminho}');\n";
  36.         }
  37.         file_put_contents("map.php", $content);
  38.         highlight_string($content);
  39.     }
  40. }
  41.  
  42. //Exemplo de como usar
  43. $MapCreator = new MapCreator(array("app/control/","app/model/"));
  44. $MapCreator->getMap();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement