Changeset 7247
- Timestamp:
- 01/31/08 15:15:49 (1 year ago)
- Files:
-
- branches/1.1/lib/autoload (added)
- branches/1.1/lib/autoload/sfAutoload.class.php (copied) (copied from trunk/lib/util/sfAutoload.class.php) (3 diffs)
- branches/1.1/lib/autoload/sfCoreAutoload.class.php (moved) (moved from branches/1.1/lib/util/sfCoreAutoload.class.php) (8 diffs)
- branches/1.1/lib/autoload/sfSimpleAutoload.class.php (copied) (copied from trunk/lib/util/sfSimpleAutoload.class.php) (10 diffs)
- branches/1.1/lib/command/sfSymfonyCommandApplication.class.php (modified) (5 diffs)
- branches/1.1/lib/plugins/sfCompat10Plugin/test/bootstrap/unit.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBaseTask.class.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildAllLoadTask.class.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildAllTask.class.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildDbTask.class.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildFormsTask.class.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildModelTask.class.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildSchemaTask.class.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildSqlTask.class.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelDataDumpTask.class.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelDataLoadTask.class.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelGenerateCrudTask.class.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelInitAdminTask.class.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelInsertSqlTask.class.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelSchemaToXmlTask.class.php (modified) (1 diff)
- branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelSchemaToYmlTask.class.php (modified) (1 diff)
- branches/1.1/lib/task/generator/sfGenerateAppTask.class.php (modified) (1 diff)
- branches/1.1/lib/task/generator/sfGenerateControllerTask.class.php (modified) (1 diff)
- branches/1.1/lib/task/generator/sfGenerateModuleTask.class.php (modified) (1 diff)
- branches/1.1/lib/task/generator/sfGenerateProjectTask.class.php (modified) (1 diff)
- branches/1.1/lib/task/plugin/sfPluginAddChannelTask.class.php (modified) (1 diff)
- branches/1.1/lib/task/plugin/sfPluginInstallTask.class.php (modified) (1 diff)
- branches/1.1/lib/task/plugin/sfPluginListTask.class.php (modified) (1 diff)
- branches/1.1/lib/task/plugin/sfPluginUninstallTask.class.php (modified) (1 diff)
- branches/1.1/lib/task/plugin/sfPluginUpgradeTask.class.php (modified) (1 diff)
- branches/1.1/lib/util/sfAutoload.class.php (deleted)
- branches/1.1/lib/util/sfCore.class.php (modified) (1 diff)
- branches/1.1/lib/util/sfSimpleAutoload.class.php (deleted)
- branches/1.1/test/bin/prove.php (modified) (2 diffs)
- branches/1.1/test/bootstrap/unit.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/autoload/sfAutoload.class.php
r5384 r7247 16 16 * 17 17 * @package symfony 18 * @subpackage autoload 18 19 * @author Fabien Potencier <fabien.potencier@symfony-project.com> 19 20 * @version SVN: $Id$ … … 32 33 } 33 34 35 /** 36 * Retrieves the singleton instance of this class. 37 * 38 * @return sfCoreAutoload A sfCoreAutoload implementation instance. 39 */ 34 40 static public function getInstance() 35 41 { … … 42 48 } 43 49 44 public function register() 50 /** 51 * Register sfAutoload in spl autoloader. 52 * 53 * @return void 54 */ 55 static public function register() 45 56 { 46 57 ini_set('unserialize_callback_func', 'spl_autoload_call'); 47 58 48 spl_autoload_register(array($this, 'autoload')); 59 if (!spl_autoload_register(array(self::getInstance(), 'autoload'))) 60 { 61 throw new sfException(sprintf('Unable to register %s::autoload as an autoloading method.', get_class(self::getInstance()))); 62 } 49 63 } 50 64 51 public function unregister() 65 /** 66 * Unregister sfAutoload from spl autoloader. 67 * 68 * @return void 69 */ 70 static public function unregister() 52 71 { 53 spl_autoload_unregister(array( $this, 'autoload'));72 spl_autoload_unregister(array(self::getInstance(), 'autoload')); 54 73 } 55 74 branches/1.1/lib/autoload/sfCoreAutoload.class.php
r7245 r7247 25 25 $instance = null; 26 26 27 protected function __construct() 28 { 29 } 30 27 31 /** 28 32 * Retrieves the singleton instance of this class. … … 45 49 * @return void 46 50 */ 47 public function register()51 static public function register() 48 52 { 49 53 ini_set('unserialize_callback_func', 'spl_autoload_call'); 50 51 spl_autoload_register(array($this, 'autoload')); 54 if (!spl_autoload_register(array(self::getInstance(), 'autoload'))) 55 { 56 throw new sfException(sprintf('Unable to register %s::autoload as an autoloading method.', get_class(self::getInstance()))); 57 } 52 58 } 53 59 … … 57 63 * @return void 58 64 */ 59 public function unregister()60 { 61 spl_autoload_unregister(array( $this, 'autoload'));65 static public function unregister() 66 { 67 spl_autoload_unregister(array(self::getInstance(), 'autoload')); 62 68 } 63 69 64 70 /** 65 * Handles autoloading of classes that have been specified in autoload.php.71 * Handles autoloading of classes. 66 72 * 67 73 * @param string A class name. … … 81 87 } 82 88 89 /** 90 * Rebuilds the association array between class names and paths. 91 * 92 * This method overrides this file (__FILE__) 93 */ 83 94 static public function make() 84 95 { … … 99 110 } 100 111 112 // Don't edit this property by hand. 113 // To update it, use sfCoreAutoload::make() 101 114 protected $classes = array ( 102 115 'sfAction' => 'action', … … 108 121 'sfData' => 'addon', 109 122 'sfPager' => 'addon', 123 'sfAutoload' => 'autoload', 124 'sfCoreAutoload' => 'autoload', 125 'sfSimpleAutoload' => 'autoload', 110 126 'sfAPCCache' => 'cache', 111 127 'sfCache' => 'cache', … … 307 323 'sfSecurityUser' => 'user', 308 324 'sfUser' => 'user', 309 'sfAutoload' => 'util',310 325 'sfBrowser' => 'util', 311 326 'sfCallable' => 'util', 312 327 'sfContext' => 'util', 313 328 'sfCore' => 'util', 314 'sfCoreAutoload' => 'util',315 329 'sfDomCssSelector' => 'util', 316 330 'sfFinder' => 'util', … … 318 332 'sfNamespacedParameterHolder' => 'util', 319 333 'sfParameterHolder' => 'util', 320 'sfSimpleAutoload' => 'util',321 334 'sfToolkit' => 'util', 322 335 'sfYaml' => 'util', 323 'sfYamlAlternative' => 'util',324 336 'sfYamlInline' => 'util', 325 337 'Spyc' => 'util', branches/1.1/lib/autoload/sfSimpleAutoload.class.php
r5508 r7247 16 16 * 17 17 * @package symfony 18 * @subpackage autoload 18 19 * @author Fabien Potencier <fabien.potencier@symfony-project.com> 19 20 * @version SVN: $Id$ … … 42 43 } 43 44 45 /** 46 * Retrieves the singleton instance of this class. 47 * 48 * @param string The file path to save the cache 49 * 50 * @return sfCoreAutoload A sfCoreAutoload implementation instance. 51 */ 44 52 static public function getInstance($cacheFile = null) 45 53 { … … 52 60 } 53 61 54 public function register() 62 /** 63 * Register sfSimpleAutoload in spl autoloader. 64 * 65 * @return void 66 */ 67 static public function register() 55 68 { 56 69 ini_set('unserialize_callback_func', 'spl_autoload_call'); 57 if (!spl_autoload_register(array($this, 'autoload'))) 58 { 59 throw new sfException(sprintf('Unable to register %s::autoload as an autoloading method.', get_class($this))); 60 } 61 62 if ($this->cacheFile) 63 { 64 register_shutdown_function(array($this, 'saveCache')); 65 } 66 } 67 68 public function unregister() 69 { 70 spl_autoload_unregister(array($this, 'autoload')); 71 } 72 70 if (!spl_autoload_register(array(self::getInstance(), 'autoload'))) 71 { 72 throw new sfException(sprintf('Unable to register %s::autoload as an autoloading method.', get_class(self::getInstance()))); 73 } 74 75 if (self::getInstance()->cacheFile) 76 { 77 register_shutdown_function(array(self::getInstance(), 'saveCache')); 78 } 79 } 80 81 /** 82 * Unregister sfSimpleAutoload from spl autoloader. 83 * 84 * @return void 85 */ 86 static public function unregister() 87 { 88 spl_autoload_unregister(array(self::getInstance(), 'autoload')); 89 } 90 91 /** 92 * Handles autoloading of classes. 93 * 94 * @param string A class name. 95 * 96 * @return boolean Returns true if the class has been loaded 97 */ 73 98 public function autoload($class) 74 99 { … … 90 115 } 91 116 117 /** 118 * Loads the cache. 119 */ 92 120 public function loadCache() 93 121 { … … 103 131 } 104 132 133 /** 134 * Saves the cache. 135 */ 105 136 public function saveCache() 106 137 { … … 113 144 } 114 145 146 /** 147 * Reloads cache. 148 */ 115 149 public function reload() 116 150 { … … 132 166 } 133 167 168 /** 169 * Removes the cache. 170 */ 134 171 public function removeCache() 135 172 { … … 137 174 } 138 175 176 /** 177 * Adds a directory to the autoloading system. 178 * 179 * @param string The directory to look for classes 180 * @param string The extension to look for 181 */ 139 182 public function addDirectory($dir, $ext = '.php') 140 183 { 141 require_once(dirname(__FILE__).'/ sfFinder.class.php');184 require_once(dirname(__FILE__).'/../util/sfFinder.class.php'); 142 185 143 186 $finder = sfFinder::type('file')->ignore_version_control()->follow_link()->name('*'.$ext); … … 161 204 } 162 205 163 public function addFiles($files, $register = true) 206 /** 207 * Adds files to the autoloading system. 208 * 209 * @param array An array of files 210 * @param Boolean Whether to register those files as single entities (used when reloading) 211 */ 212 public function addFiles(array $files, $register = true) 164 213 { 165 214 foreach ($files as $file) … … 169 218 } 170 219 220 /** 221 * Adds a file to the autoloading system. 222 * 223 * @param string A file path 224 * @param Boolean Whether to register those files as single entities (used when reloading) 225 */ 171 226 public function addFile($file, $register = true) 172 227 { branches/1.1/lib/command/sfSymfonyCommandApplication.class.php
r6155 r7247 19 19 class sfSymfonyCommandApplication extends sfCommandApplication 20 20 { 21 protected22 $autoloader = null;23 24 21 /** 25 22 * Configures the current symfony command application. … … 40 37 } 41 38 42 require_once($this->options['symfony_lib_dir'].'/util/sfCore.class.php');43 require_once($this->options['symfony_lib_dir'].'/ config/sfConfig.class.php');44 require_once($this->options['symfony_lib_dir'].'/util/sfSimpleAutoload.class.php');39 // initialize symfony core autoloading 40 require_once($this->options['symfony_lib_dir'].'/autoload/sfCoreAutoload.class.php'); 41 sfCoreAutoload::getInstance()->register(); 45 42 46 43 // application … … 84 81 85 82 /** 86 * Returns the autoloader object.87 *88 * @param object The autoloader object89 */90 public function getAutoloader()91 {92 return $this->autoloader;93 }94 95 /**96 83 * Initializes the environment variables and include path. 97 84 * … … 132 119 else 133 120 { 134 require_once(sfConfig::get('sf_symfony_lib_dir').'/util/sfToolkit.class.php');135 121 $cache = sfToolkit::getTmpDir().DIRECTORY_SEPARATOR.sprintf('sf_autoload_cmd_%s.data', md5(__FILE__)); 136 122 } … … 138 124 $this->autoloader = sfSimpleAutoload::getInstance($cache); 139 125 $this->autoloader->register(); 140 141 require_once(sfConfig::get('sf_symfony_lib_dir').'/util/sfFinder.class.php');142 $finder = sfFinder::type('file')->ignore_version_control()->prune('test')->prune('vendor')->name('*.php');143 $this->autoloader->addFiles($finder->in(sfConfig::get('sf_symfony_lib_dir')));144 126 $this->autoloader->addDirectory(sfConfig::get('sf_root_dir').'/plugins'); 145 127 } branches/1.1/lib/plugins/sfCompat10Plugin/test/bootstrap/unit.php
r5395 r7247 15 15 sfConfig::set('sf_symfony_data_dir', realpath($_test_dir.'/../data')); 16 16 17 require_once(dirname(__FILE__).'/../../../../ util/sfSimpleAutoload.class.php');17 require_once(dirname(__FILE__).'/../../../../autoload/sfSimpleAutoload.class.php'); 18 18 require_once(dirname(__FILE__).'/../../../../util/sfToolkit.class.php'); 19 19 $autoload = sfSimpleAutoload::getInstance(sfToolkit::getTmpDir().DIRECTORY_SEPARATOR.sprintf('sf_autoload_unit_%s.data', md5(__FILE__))); branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBaseTask.class.php
r7182 r7247 33 33 if (!self::$done) 34 34 { 35 $libDir = dirname(__FILE__).'/..'; 36 35 37 $autoloader = sfSimpleAutoload::getInstance(); 36 $autoloader->addDirectory(dirname(__FILE__).'/../vendor/creole'); 37 $autoloader->addDirectory(dirname(__FILE__).'/../vendor/propel'); 38 $autoloader->addDirectory($libDir.'/vendor/creole'); 39 $autoloader->addDirectory($libDir.'/vendor/propel'); 40 $autoloader->addDirectory($libDir.'/creole'); 41 $autoloader->addDirectory($libDir.'/propel'); 42 $autoloader->addDirectory($libDir.'/task'); 38 43 $autoloader->addDirectory(sfConfig::get('sf_root_dir').'/lib/model'); 39 44 $autoloader->addDirectory(sfConfig::get('sf_root_dir').'/lib/form'); 45 $autoloader->register(); 40 46 41 47 self::$done = true; branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildAllLoadTask.class.php
r6174 r7247 8 8 * file that was distributed with this source code. 9 9 */ 10 11 require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php'); 10 12 11 13 /** branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildAllTask.class.php
r6174 r7247 8 8 * file that was distributed with this source code. 9 9 */ 10 11 require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php'); 10 12 11 13 /** branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildDbTask.class.php
r5504 r7247 8 8 * file that was distributed with this source code. 9 9 */ 10 11 require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php'); 10 12 11 13 /** branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildFormsTask.class.php
r6174 r7247 8 8 * file that was distributed with this source code. 9 9 */ 10 11 require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php'); 10 12 11 13 /** branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildModelTask.class.php
r5504 r7247 8 8 * file that was distributed with this source code. 9 9 */ 10 11 require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php'); 10 12 11 13 /** branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildSchemaTask.class.php
r5504 r7247 8 8 * file that was distributed with this source code. 9 9 */ 10 11 require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php'); 10 12 11 13 /** branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildSqlTask.class.php
r5504 r7247 8 8 * file that was distributed with this source code. 9 9 */ 10 11 require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php'); 10 12 11 13 /** branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelDataDumpTask.class.php
r6021 r7247 8 8 * file that was distributed with this source code. 9 9 */ 10 11 require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php'); 10 12 11 13 /** branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelDataLoadTask.class.php
r5504 r7247 8 8 * file that was distributed with this source code. 9 9 */ 10 11 require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php'); 10 12 11 13 /** branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelGenerateCrudTask.class.php
r6882 r7247 8 8 * file that was distributed with this source code. 9 9 */ 10 11 require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php'); 10 12 11 13 /** branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelInitAdminTask.class.php
r6097 r7247 8 8 * file that was distributed with this source code. 9 9 */ 10 11 require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php'); 10 12 11 13 /** branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelInsertSqlTask.class.php
r5504 r7247 8 8 * file that was distributed with this source code. 9 9 */ 10 11 require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php'); 10 12 11 13 /** branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelSchemaToXmlTask.class.php
r5504 r7247 8 8 * file that was distributed with this source code. 9 9 */ 10 11 require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php'); 10 12 11 13 /** branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelSchemaToYmlTask.class.php
r5504 r7247 8 8 * file that was distributed with this source code. 9 9 */ 10 11 require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php'); 10 12 11 13 /** branches/1.1/lib/task/generator/sfGenerateAppTask.class.php
r6931 r7247 8 8 * file that was distributed with this source code. 9 9 */ 10 11 require_once(dirname(__FILE__).'/sfGeneratorBaseTask.class.php'); 10 12 11 13 /** branches/1.1/lib/task/generator/sfGenerateControllerTask.class.php
r6931 r7247 8 8 * file that was distributed with this source code. 9 9 */ 10 11 require_once(dirname(__FILE__).'/sfGeneratorBaseTask.class.php'); 10 12 11 13 /** branches/1.1/lib/task/generator/sfGenerateModuleTask.class.php
r6931 r7247 8 8 * file that was distributed with this source code. 9 9 */ 10 11 require_once(dirname(__FILE__).'/sfGeneratorBaseTask.class.php'); 10 12 11 13 /** branches/1.1/lib/task/generator/sfGenerateProjectTask.class.php
r6931 r7247 8 8 * file that was distributed with this source code. 9 9 */ 10 11 require_once(dirname(__FILE__).'/sfGeneratorBaseTask.class.php'); 10 12 11 13 /** branches/1.1/lib/task/plugin/sfPluginAddChannelTask.class.php
r6931 r7247 8 8 * file that was distributed with this source code. 9 9 */ 10 11 require_once(dirname(__FILE__).'/sfPluginBaseTask.class.php'); 10 12 11 13 /** branches/1.1/lib/task/plugin/sfPluginInstallTask.class.php
r6931 r7247 8 8 * file that was distributed with this source code. 9 9 */ 10 11 require_once(dirname(__FILE__).'/sfPluginBaseTask.class.php'); 10 12 11 13 /** branches/1.1/lib/task/plugin/sfPluginListTask.class.php
r6931 r7247 8 8 * file that was distributed with this source code. 9 9 */ 10 11 require_once(dirname(__FILE__).'/sfPluginBaseTask.class.php'); 10 12 11 13 /** branches/1.1/lib/task/plugin/sfPluginUninstallTask.class.php
r6931 r7247 8 8 * file that was distributed with this source code. 9 9 */ 10 11 require_once(dirname(__FILE__).'/sfPluginBaseTask.class.php'); 10 12 11 13 /** branches/1.1/lib/task/plugin/sfPluginUpgradeTask.class.php
r6931 r7247 8 8 * file that was distributed with this source code. 9 9 */ 10 11 require_once(dirname(__FILE__).'/sfPluginBaseTask.class.php'); 10 12 11 13 /** branches/1.1/lib/util/sfCore.class.php
r7243 r7247 119 119 static public function initConfiguration($sf_symfony_lib_dir, $sf_symfony_data_dir, $test = false) 120 120 { 121 require_once($sf_symfony_lib_dir.'/ util/sfCoreAutoload.class.php');121 require_once($sf_symfony_lib_dir.'/autoload/sfCoreAutoload.class.php'); 122 122 sfCoreAutoload::getInstance()->register(); 123 123 branches/1.1/test/bin/prove.php
r7243 r7247 28 28 29 29 $h->base_dir = realpath(dirname(__FILE__).'/..'); 30 require_once(dirname(__FILE__).'/../../lib/ util/sfSimpleAutoload.class.php');30 require_once(dirname(__FILE__).'/../../lib/autoload/sfSimpleAutoload.class.php'); 31 31 require_once(dirname(__FILE__).'/../../lib/util/sfToolkit.class.php'); 32 32 $autoload = sfSimpleAutoload::getInstance(sfToolkit::getTmpDir().DIRECTORY_SEPARATOR.sprintf('sf_autoload_unit_%s.data', md5(__FILE__))); … … 34 34 35 35 // update sfCoreAutoload 36 require_once(dirname(__FILE__).'/../../lib/ util/sfCoreAutoload.class.php');36 require_once(dirname(__FILE__).'/../../lib/autoload/sfCoreAutoload.class.php'); 37 37 sfCoreAutoload::make(); 38 38 branches/1.1/test/bootstrap/unit.php
r6870 r7247 23 23 sfConfig::set('sf_symfony_data_dir', realpath($_test_dir.'/../data')); 24 24 25 require_once(dirname(__FILE__).'/../../lib/ util/sfSimpleAutoload.class.php');25 require_once(dirname(__FILE__).'/../../lib/autoload/sfSimpleAutoload.class.php'); 26 26 require_once(dirname(__FILE__).'/../../lib/util/sfToolkit.class.php'); 27 27 $autoload = sfSimpleAutoload::getInstance(sfToolkit::getTmpDir().DIRECTORY_SEPARATOR.sprintf('sf_autoload_unit_%s.data', md5(__FILE__)));

