Example #1
0
 /**
  * Checks if macro is registered.
  *
  * @param string $name
  * @return bool 
  * @static 
  */
 public static function hasMacro($name)
 {
     return \Illuminate\Filesystem\Filesystem::hasMacro($name);
 }
<?php

namespace Propaganistas\LaravelHelperMacros\Macros;

use Illuminate\Filesystem\Filesystem;
if (!Filesystem::hasMacro('globRecursive')) {
    /**
     * Recursively find pathnames matching a pattern.
     *
     * @param string $pattern
     * @param int    $flags
     * @return array
     */
    Filesystem::macro('globRecursive', function ($pattern, $flags = 0) {
        $files = glob($pattern, $flags);
        foreach (glob(dirname($pattern) . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
            $files = array_merge($files, Filesystem::globRecursive($dir . '/' . basename($pattern), $flags));
        }
        return $files;
    });
}