WPDKFilesystem::recursiveScan PHP Méthode

recursiveScan() public static méthode

wpdk_rglob_find_dir( true, $file ) - when find a dir wpdk_rglob_find_file( true, $file ) - when find a a file wpdk_rglob_matched( $regexp_result, $file, $match ) - after preg_match() done
Since: 1.0.0.b4
public static recursiveScan ( string $path, string $match = '' ) : array
$path string Folder root
$match string Optional. Regex to apply on file name. For example use '/^.*\.(php)$/i' to get only php file. Default is empty
Résultat array
    public static function recursiveScan($path, $match = '')
    {
        /**
         * Return an array with all matched files from root folder.
         *
         * @brief get all matched files
         * @note  Internal recursive use only
         *
         * @param string $path    Folder root
         * @param string $match   Optional. Regex to apply on file name. For example use '/^.*\.(php)$/i' to get only php file
         * @param array  &$result Optional. Result array. Empty form first call
         *
         * @return array
         */
        function _rglob($path, $match = '', &$result = array())
        {
            $files = glob(trailingslashit($path) . '*', GLOB_MARK);
            if (false !== $files) {
                foreach ($files as $file) {
                    if (is_dir($file)) {
                        $continue = apply_filters('wpdk_rglob_find_dir', true, $file);
                        if ($continue) {
                            _rglob($file, $match, $result);
                        }
                    } elseif (!empty($match)) {
                        $continue = apply_filters('wpdk_rglob_find_file', true, $file);
                        if (false == $continue) {
                            break;
                        }
                        $regexp_result = array();
                        $error = preg_match($match, $file, $regexp_result);
                        if (0 !== $error || false !== $error) {
                            $regexp_result = apply_filters('wpdk_rglob_matched', $regexp_result, $file, $match);
                            if (!empty($regexp_result)) {
                                $result[] = $regexp_result[0];
                            }
                        }
                    } else {
                        $result[] = $file;
                    }
                }
                return $result;
            }
        }
        $result = array();
        return _rglob($path, $match, $result);
    }