diff --git a/.gitignore b/.gitignore index 987e2a2..15977fb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ composer.lock vendor +mustache.php diff --git a/.gitmodules b/.gitmodules index 042ea4d..ee478af 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "vendor/yaml"] path = vendor/yaml url = https://github.com/fabpot/yaml.git +[submodule "vendor/symfony/Symfony/Component/ClassLoader"] + path = vendor/symfony/Symfony/Component/ClassLoader + url = https://github.com/symfony/ClassLoader.git diff --git a/bin/build_bootstrap.php b/bin/build_bootstrap.php new file mode 100755 index 0000000..fe7b632 --- /dev/null +++ b/bin/build_bootstrap.php @@ -0,0 +1,151 @@ +#!/usr/bin/env php + + */ +class SymfonyClassCollectionLoader +{ + static private $loaded; + + /** + * Loads a list of classes and caches them in one big file. + * + * @param array $classes An array of classes to load + * @param string $cacheDir A cache directory + * @param string $name The cache name prefix + * @param string $extension File extension of the resulting file + * + * @throws InvalidArgumentException When class can't be loaded + */ + static public function load(array $classes, $cacheDir, $name, $extension = '.php') + { + // each $name can only be loaded once per PHP process + if (isset(self::$loaded[$name])) { + return; + } + + self::$loaded[$name] = true; + + $content = ''; + foreach ($classes as $class) { + if (!class_exists($class) && !interface_exists($class) && (!function_exists('trait_exists') || !trait_exists($class))) { + throw new InvalidArgumentException(sprintf('Unable to load class "%s"', $class)); + } + + $r = new ReflectionClass($class); + $content .= preg_replace(array('/^\s*<\?php/', '/\?>\s*$/'), '', file_get_contents($r->getFileName())); + } + + $cache = $cacheDir.'/'.$name.$extension; + self::writeCacheFile($cache, self::stripComments('