src/sb/Controller/Toolkit.php
protected function grabFile($file, $root)
    {
        $data = '';
        if (is_file($root . '/' . $file)) {

            $this->loaded_files[] = $file;

            $file = $root . '/' . $file;

            $data = file_get_contents($file);
            if (!strstr($file, 'sb.js')) {
                preg_match_all("~sb\.include\([\"'](.*?)[\"']~", $data, $includes);

                if ($includes[1]) {
                    $precludes = '';
                    foreach ($includes[1] as $include) {
                        $include = \str_replace('.', '/', $include) . '.js';
                        if (!\in_array($include, $this->loaded_files)) {
                            $precludes .= $this->grabFile($include, $root);
                        }
                    }

                    $data = $precludes . "\n" . $data;
                }
            }
        } else {

            echo"\nthrow('ERROR: " . $file . " Surebert module \""
            . \basename($file) . "\" could not be located by /surebert/load ');";
        }

        return $data;
    }
protected function grabFile($file, $root)
    {
        $data = '';
        if (is_file($root . '/' . $file)) {

            $this->loaded_files[] = $file;

            $file = $root . '/' . $file;

            $data = file_get_contents($file);
            if (!strstr($file, 'sb.js')) {
                preg_match_all("~sb\.include\([\"'](.*?)[\"']~", $data, $includes);

                if ($includes[1]) {
                    $precludes = '';
                    foreach ($includes[1] as $include) {
                        $include = \str_replace('.', '/', $include) . '.js';
                        if (!\in_array($include, $this->loaded_files)) {
                            $precludes .= $this->grabFile($include, $root);
                        }
                    }

                    $data = $precludes . "\n" . $data;
                }
            }
        } else {

            echo"\nthrow('ERROR: " . $file . " Surebert module \""
            . \basename($file) . "\" could not be located by /surebert/load ');";
        }

        return $data;
    }
protected function grabFile ( $ file , $ root ) { $ data = '' ; if ( is_file ( $ root . '/' . $ file ) ) { $ this -> loaded_files [ ] = $ file ; $ file = $ root . '/' . $ file ; $ data = file_get_contents ( $ file ) ; if ( ! strstr ( $ file , 'sb.js' ) ) { preg_match_all ( "~sb\.include\([\"'](.*?)[\"']~" , $ data , $ includes ) ; if ( $ includes [ 1 ] ) { $ precludes = '' ; foreach ( $ includes [ 1 ] as $ include ) { $ include = \ str_replace ( '.' , '/' , $ include ) . '.js' ; if ( ! \ in_array ( $ include , $ this -> loaded_files ) ) { $ precludes .= $ this -> grabFile ( $ include , $ root ) ; } } $ data = $ precludes . "\n" . $ data ; } } } else { echo "\nthrow('ERROR: " . $ file . " Surebert module \"" . \ basename ( $ file ) . "\" could not be located by /surebert/load ');" ; } return $ data ; }
Grabs a file
@param string $file The file to load
@param string $root The root to load
@return string The file data
Grabs a file