| 1 |
<?php |
| 2 |
|
| 3 |
namespace AgeGate\Integration; |
| 4 |
|
| 5 |
use RecursiveIteratorIterator; |
| 6 |
use RecursiveDirectoryIterator; |
| 7 |
|
| 8 |
class Discover |
| 9 |
{ |
| 10 |
public function __construct() |
| 11 |
{ |
| 12 |
$rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(dirname(__FILE__))); |
| 13 |
|
| 14 |
$files = []; |
| 15 |
|
| 16 |
foreach ($rii as $file) { |
| 17 |
if ($file->isDir()) { |
| 18 |
continue; |
| 19 |
} |
| 20 |
|
| 21 |
$class = trim(str_replace($file->getExtension(), '', $file->getFilename()), '.'); |
| 22 |
|
| 23 |
|
| 24 |
$ns = 'AgeGate' . str_replace(AGE_GATE_PATH . 'src', '', $file->getPath()) . '/' . $class; |
| 25 |
|
| 26 |
$class = str_replace('/', '\\', $ns); |
| 27 |
|
| 28 |
if ($class === __CLASS__) { |
| 29 |
continue; |
| 30 |
} |
| 31 |
|
| 32 |
if (class_exists($class)) { |
| 33 |
(new $class)->init(); |
| 34 |
} |
| 35 |
|
| 36 |
$files[] = $file->getPathname(); |
| 37 |
} |
| 38 |
} |
| 39 |
} |
| 40 |
|