PHPDaemon\Core\Daemon::glob PHP Method

glob() public static method

Glob function with support of include_path
public static glob ( string $pattern, integer $flags ) : array
$pattern string
$flags integer
return array
    public static function glob($pattern, $flags = 0)
    {
        $r = [];
        foreach (explode(':', get_include_path()) as $path) {
            $r = array_merge($r, glob($p = $path . '/' . $pattern, $flags));
        }
        return array_unique($r);
    }

Usage Example

Beispiel #1
0
 protected function discoverOrm($path, $prefix = '\\WakePHP\\ORM\\')
 {
     foreach (Daemon::glob($path) as $file) {
         $class = strstr(basename($file), '.', true);
         if ($class === 'Generic') {
             continue;
         }
         $prop = preg_replace_callback('~^[A-Z]+~', function ($m) {
             return strtolower($m[0]);
         }, $class);
         $class = $prefix . $class;
         if (!class_exists($class)) {
             continue;
         }
         $this->{$prop} =& $a;
         // trick ;-)
         unset($a);
         $this->{$prop} = new $class($this);
     }
 }