|
@ -20,14 +20,17 @@ class AutoloadBuilder |
|
|
|
|
|
|
|
|
protected $dirs; |
|
|
protected $dirs; |
|
|
|
|
|
|
|
|
|
|
|
protected $exclude; |
|
|
|
|
|
|
|
|
protected $handler; |
|
|
protected $handler; |
|
|
|
|
|
|
|
|
protected $regex = '/(class|interface) ([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)/'; |
|
|
protected $regex = '/(class|interface) ([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)/'; |
|
|
|
|
|
|
|
|
public function __construct($autoload, $dirs = array()) |
|
|
|
|
|
|
|
|
public function __construct($autoload, $dirs = array(), $exclude = array()) |
|
|
{ |
|
|
{ |
|
|
$this->autoload = $autoload; |
|
|
$this->autoload = $autoload; |
|
|
$this->dirs = $dirs; |
|
|
$this->dirs = $dirs; |
|
|
|
|
|
$this->exclude = $exclude; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function build() |
|
|
public function build() |
|
@ -42,6 +45,10 @@ class AutoloadBuilder |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
foreach ($iterator as $file) { |
|
|
foreach ($iterator as $file) { |
|
|
|
|
|
|
|
|
|
|
|
if($this->isExcluded($file->getRealPath())) { |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
// skip non php files
|
|
|
// skip non php files
|
|
|
$e = explode('.', $file->getFileName()); |
|
|
$e = explode('.', $file->getFileName()); |
|
|
if ((end($e) !== 'php') || $this->rightSubstr($file->getFileName(), 8) == 'Test.php') { |
|
|
if ((end($e) !== 'php') || $this->rightSubstr($file->getFileName(), 8) == 'Test.php') { |
|
@ -68,6 +75,17 @@ class AutoloadBuilder |
|
|
$this->closeAutoload(); |
|
|
$this->closeAutoload(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected function isExcluded($file) |
|
|
|
|
|
{ |
|
|
|
|
|
foreach ($this->exclude as $dir) { |
|
|
|
|
|
if (stripos($file, PATH . $dir) === 0) { |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected function openAutoload() |
|
|
protected function openAutoload() |
|
|
{ |
|
|
{ |
|
|
$this->write("<?php\n// This file is autogenerated by \n// " . __FILE__ . " script.\nreturn array(\n"); |
|
|
$this->write("<?php\n// This file is autogenerated by \n// " . __FILE__ . " script.\nreturn array(\n"); |
|
|