Source for file Loader.php
Documentation is available at Loader.php
* handles plugin loading and caching of plugins names/paths relationships
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
* @author Jordi Boggiano <j.boggiano@seld.be>
* @copyright Copyright (c) 2008, Jordi Boggiano
* @license http://dwoo.org/LICENSE Modified BSD License
* stores the plugin directories
* stores the plugins names/paths relationships
* don't edit this on your own, use addDirectory
* path where class paths cache files are written
$this->cacheDir =
rtrim($cacheDir, DIRECTORY_SEPARATOR) .
DIRECTORY_SEPARATOR;
// include class paths or rebuild paths if the cache file isn't there
* rebuilds class paths, scans the given directory recursively and saves all paths in the given file
* @param string $path the plugin path to scan
* @param string $cacheFile the file where to store the plugin paths cache, it will be overwritten
if ($cacheFile!==
false) {
// iterates over all files/folders
$list =
glob(rtrim($path, DIRECTORY_SEPARATOR) .
DIRECTORY_SEPARATOR .
'*');
$this->classPath[str_replace(array('function.','block.','modifier.','outputfilter.','filter.','prefilter.','postfilter.','pre.','post.','output.','shared.','helper.'), '', basename($f, '.php'))] =
$f;
// save in file if it's the first call (not recursed)
if ($cacheFile!==
false) {
throw
new Dwoo_Exception('Could not write into '.
$cacheFile.
', either because the folder is not there (create it) or because of the chmod configuration (please ensure this directory is writable by php), alternatively you can change the directory used with $dwoo->setCompileDir() or provide a custom loader object with $dwoo->setLoader()');
* @param string $class the plugin name, without the Dwoo_Plugin_ prefix
* @param bool $forceRehash if true, the class path caches will be rebuilt if the plugin is not found, in case it has just been added, defaults to true
public function loadPlugin($class, $forceRehash =
true)
// a new class was added or the include failed so we rebuild the cache
foreach ($this->paths as $path=>
$file) {
throw
new Dwoo_Exception('Plugin <em>'.
$class.
'</em> can not be found, maybe you forgot to bind it if it\'s a custom plugin ?', E_USER_NOTICE);
throw
new Dwoo_Exception('Plugin <em>'.
$class.
'</em> can not be found, maybe you forgot to bind it if it\'s a custom plugin ?', E_USER_NOTICE);
* adds a plugin directory, the plugins found in the new plugin directory
* will take precedence over the other directories (including the default
* dwoo plugin directory), you can use this for example to override plugins
* in a specific directory for a specific application while keeping all your
* usual plugins in the same place for all applications.
* TOCOM don't forget that php functions overrides are not rehashed so you
* need to clear the classpath caches by hand when adding those
* @param string $pluginDirectory the plugin path to scan
$pluginDir =
realpath($pluginDirectory);
throw
new Dwoo_Exception('Plugin directory does not exist or can not be read : '.
$pluginDirectory);
$cacheFile =
$this->cacheDir .
'classpath-'.
substr(strtr($pluginDir, '/\\:'.
PATH_SEPARATOR, '----'), strlen($pluginDir) >
80 ? -
80 :
0).
'.d'.
Dwoo::RELEASE_TAG.
'.php';
$this->paths[$pluginDir] =
$cacheFile;
Documentation generated on Sat, 18 Jul 2009 21:05:12 +0200 by phpDocumentor 1.4.0