Development

Changeset 7247

You must first sign up to be able to contribute.

Changeset 7247

Show
Ignore:
Timestamp:
01/31/08 15:15:49 (7 months ago)
Author:
fabien
Message:

moved all autoload classes to lib/autoload

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/lib/autoload/sfAutoload.class.php

    r5384 r7247  
    1616 * 
    1717 * @package    symfony 
     18 * @subpackage autoload 
    1819 * @author     Fabien Potencier <fabien.potencier@symfony-project.com> 
    1920 * @version    SVN: $Id$ 
     
    3233  } 
    3334 
     35  /** 
     36   * Retrieves the singleton instance of this class. 
     37   * 
     38   * @return sfCoreAutoload A sfCoreAutoload implementation instance. 
     39   */ 
    3440  static public function getInstance() 
    3541  { 
     
    4248  } 
    4349 
    44   public function register() 
     50  /** 
     51   * Register sfAutoload in spl autoloader. 
     52   * 
     53   * @return void 
     54   */ 
     55  static public function register() 
    4556  { 
    4657    ini_set('unserialize_callback_func', 'spl_autoload_call'); 
    4758 
    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    } 
    4963  } 
    5064 
    51   public function unregister() 
     65  /** 
     66   * Unregister sfAutoload from spl autoloader. 
     67   * 
     68   * @return void 
     69   */ 
     70  static public function unregister() 
    5271  { 
    53     spl_autoload_unregister(array($this, 'autoload')); 
     72    spl_autoload_unregister(array(self::getInstance(), 'autoload')); 
    5473  } 
    5574 
  • branches/1.1/lib/autoload/sfCoreAutoload.class.php

    r7245 r7247  
    2525    $instance = null; 
    2626 
     27  protected function __construct() 
     28  { 
     29  } 
     30 
    2731  /** 
    2832   * Retrieves the singleton instance of this class. 
     
    4549   * @return void 
    4650   */ 
    47   public function register() 
     51  static public function register() 
    4852  { 
    4953    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    } 
    5258  } 
    5359 
     
    5763   * @return void 
    5864   */ 
    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')); 
    6268  } 
    6369 
    6470  /** 
    65    * Handles autoloading of classes that have been specified in autoload.php
     71   * Handles autoloading of classes
    6672   * 
    6773   * @param  string  A class name. 
     
    8187  } 
    8288 
     89  /** 
     90   * Rebuilds the association array between class names and paths. 
     91   * 
     92   * This method overrides this file (__FILE__) 
     93   */ 
    8394  static public function make() 
    8495  { 
     
    99110  } 
    100111 
     112  // Don't edit this property by hand. 
     113  // To update it, use sfCoreAutoload::make() 
    101114  protected $classes = array ( 
    102115  'sfAction' => 'action', 
     
    108121  'sfData' => 'addon', 
    109122  'sfPager' => 'addon', 
     123  'sfAutoload' => 'autoload', 
     124  'sfCoreAutoload' => 'autoload', 
     125  'sfSimpleAutoload' => 'autoload', 
    110126  'sfAPCCache' => 'cache', 
    111127  'sfCache' => 'cache', 
     
    307323  'sfSecurityUser' => 'user', 
    308324  'sfUser' => 'user', 
    309   'sfAutoload' => 'util', 
    310325  'sfBrowser' => 'util', 
    311326  'sfCallable' => 'util', 
    312327  'sfContext' => 'util', 
    313328  'sfCore' => 'util', 
    314   'sfCoreAutoload' => 'util', 
    315329  'sfDomCssSelector' => 'util', 
    316330  'sfFinder' => 'util', 
     
    318332  'sfNamespacedParameterHolder' => 'util', 
    319333  'sfParameterHolder' => 'util', 
    320   'sfSimpleAutoload' => 'util', 
    321334  'sfToolkit' => 'util', 
    322335  'sfYaml' => 'util', 
    323   'sfYamlAlternative' => 'util', 
    324336  'sfYamlInline' => 'util', 
    325337  'Spyc' => 'util', 
  • branches/1.1/lib/autoload/sfSimpleAutoload.class.php

    r5508 r7247  
    1616 * 
    1717 * @package    symfony 
     18 * @subpackage autoload 
    1819 * @author     Fabien Potencier <fabien.potencier@symfony-project.com> 
    1920 * @version    SVN: $Id$ 
     
    4243  } 
    4344 
     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   */ 
    4452  static public function getInstance($cacheFile = null) 
    4553  { 
     
    5260  } 
    5361 
    54   public function register() 
     62  /** 
     63   * Register sfSimpleAutoload in spl autoloader. 
     64   * 
     65   * @return void 
     66   */ 
     67  static public function register() 
    5568  { 
    5669    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   */ 
    7398  public function autoload($class) 
    7499  { 
     
    90115  } 
    91116 
     117  /** 
     118   * Loads the cache. 
     119   */ 
    92120  public function loadCache() 
    93121  { 
     
    103131  } 
    104132 
     133  /** 
     134   * Saves the cache. 
     135   */ 
    105136  public function saveCache() 
    106137  { 
     
    113144  } 
    114145 
     146  /** 
     147   * Reloads cache. 
     148   */ 
    115149  public function reload() 
    116150  { 
     
    132166  } 
    133167 
     168  /** 
     169   * Removes the cache. 
     170   */ 
    134171  public function removeCache() 
    135172  { 
     
    137174  } 
    138175 
     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   */ 
    139182  public function addDirectory($dir, $ext = '.php') 
    140183  { 
    141     require_once(dirname(__FILE__).'/sfFinder.class.php'); 
     184    require_once(dirname(__FILE__).'/../util/sfFinder.class.php'); 
    142185 
    143186    $finder = sfFinder::type('file')->ignore_version_control()->follow_link()->name('*'.$ext); 
     
    161204  } 
    162205 
    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) 
    164213  { 
    165214    foreach ($files as $file) 
     
    169218  } 
    170219 
     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   */ 
    171226  public function addFile($file, $register = true) 
    172227  { 
  • branches/1.1/lib/command/sfSymfonyCommandApplication.class.php

    r6155 r7247  
    1919class sfSymfonyCommandApplication extends sfCommandApplication 
    2020{ 
    21   protected 
    22     $autoloader = null; 
    23  
    2421  /** 
    2522   * Configures the current symfony command application. 
     
    4037    } 
    4138 
    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(); 
    4542 
    4643    // application 
     
    8481 
    8582  /** 
    86    * Returns the autoloader object. 
    87    * 
    88    * @param object The autoloader object 
    89    */ 
    90   public function getAutoloader() 
    91   { 
    92     return $this->autoloader; 
    93   } 
    94  
    95   /** 
    9683   * Initializes the environment variables and include path. 
    9784   * 
     
    132119    else 
    133120    { 
    134       require_once(sfConfig::get('sf_symfony_lib_dir').'/util/sfToolkit.class.php'); 
    135121      $cache = sfToolkit::getTmpDir().DIRECTORY_SEPARATOR.sprintf('sf_autoload_cmd_%s.data', md5(__FILE__)); 
    136122    } 
     
    138124    $this->autoloader = sfSimpleAutoload::getInstance($cache); 
    139125    $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'))); 
    144126    $this->autoloader->addDirectory(sfConfig::get('sf_root_dir').'/plugins'); 
    145127  } 
  • branches/1.1/lib/plugins/sfCompat10Plugin/test/bootstrap/unit.php

    r5395 r7247  
    1515sfConfig::set('sf_symfony_data_dir', realpath($_test_dir.'/../data')); 
    1616 
    17 require_once(dirname(__FILE__).'/../../../../util/sfSimpleAutoload.class.php'); 
     17require_once(dirname(__FILE__).'/../../../../autoload/sfSimpleAutoload.class.php'); 
    1818require_once(dirname(__FILE__).'/../../../../util/sfToolkit.class.php'); 
    1919$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  
    3333    if (!self::$done) 
    3434    { 
     35      $libDir = dirname(__FILE__).'/..'; 
     36 
    3537      $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'); 
    3843      $autoloader->addDirectory(sfConfig::get('sf_root_dir').'/lib/model'); 
    3944      $autoloader->addDirectory(sfConfig::get('sf_root_dir').'/lib/form'); 
     45      $autoloader->register(); 
    4046 
    4147      self::$done = true; 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildAllLoadTask.class.php

    r6174 r7247  
    88 * file that was distributed with this source code. 
    99 */ 
     10 
     11require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php'); 
    1012 
    1113/** 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildAllTask.class.php

    r6174 r7247  
    88 * file that was distributed with this source code. 
    99 */ 
     10 
     11require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php'); 
    1012 
    1113/** 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildDbTask.class.php

    r5504 r7247  
    88 * file that was distributed with this source code. 
    99 */ 
     10 
     11require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php'); 
    1012 
    1113/** 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildFormsTask.class.php

    r6174 r7247  
    88 * file that was distributed with this source code. 
    99 */ 
     10 
     11require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php'); 
    1012 
    1113/** 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildModelTask.class.php

    r5504 r7247  
    88 * file that was distributed with this source code. 
    99 */ 
     10 
     11require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php'); 
    1012 
    1113/** 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildSchemaTask.class.php

    r5504 r7247  
    88 * file that was distributed with this source code. 
    99 */ 
     10 
     11require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php'); 
    1012 
    1113/** 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildSqlTask.class.php

    r5504 r7247  
    88 * file that was distributed with this source code. 
    99 */ 
     10 
     11require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php'); 
    1012 
    1113/** 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelDataDumpTask.class.php

    r6021 r7247  
    88 * file that was distributed with this source code. 
    99 */ 
     10 
     11require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php'); 
    1012 
    1113/** 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelDataLoadTask.class.php

    r5504 r7247  
    88 * file that was distributed with this source code. 
    99 */ 
     10 
     11require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php'); 
    1012 
    1113/** 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelGenerateCrudTask.class.php

    r6882 r7247  
    88 * file that was distributed with this source code. 
    99 */ 
     10 
     11require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php'); 
    1012 
    1113/** 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelInitAdminTask.class.php

    r6097 r7247  
    88 * file that was distributed with this source code. 
    99 */ 
     10 
     11require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php'); 
    1012 
    1113/** 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelInsertSqlTask.class.php

    r5504 r7247  
    88 * file that was distributed with this source code. 
    99 */ 
     10 
     11require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php'); 
    1012 
    1113/** 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelSchemaToXmlTask.class.php

    r5504 r7247  
    88 * file that was distributed with this source code. 
    99 */ 
     10 
     11require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php'); 
    1012 
    1113/** 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelSchemaToYmlTask.class.php

    r5504 r7247  
    88 * file that was distributed with this source code. 
    99 */ 
     10 
     11require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php'); 
    1012 
    1113/** 
  • branches/1.1/lib/task/generator/sfGenerateAppTask.class.php

    r6931 r7247  
    88 * file that was distributed with this source code. 
    99 */ 
     10 
     11require_once(dirname(__FILE__).'/sfGeneratorBaseTask.class.php'); 
    1012 
    1113/** 
  • branches/1.1/lib/task/generator/sfGenerateControllerTask.class.php

    r6931 r7247  
    88 * file that was distributed with this source code. 
    99 */ 
     10 
     11require_once(dirname(__FILE__).'/sfGeneratorBaseTask.class.php'); 
    1012 
    1113/** 
  • branches/1.1/lib/task/generator/sfGenerateModuleTask.class.php

    r6931 r7247  
    88 * file that was distributed with this source code. 
    99 */ 
     10 
     11require_once(dirname(__FILE__).'/sfGeneratorBaseTask.class.php'); 
    1012 
    1113/** 
  • branches/1.1/lib/task/generator/sfGenerateProjectTask.class.php

    r6931 r7247  
    88 * file that was distributed with this source code. 
    99 */ 
     10 
     11require_once(dirname(__FILE__).'/sfGeneratorBaseTask.class.php'); 
    1012 
    1113/** 
  • branches/1.1/lib/task/plugin/sfPluginAddChannelTask.class.php

    r6931 r7247  
    88 * file that was distributed with this source code. 
    99 */ 
     10 
     11require_once(dirname(__FILE__).'/sfPluginBaseTask.class.php'); 
    1012 
    1113/** 
  • branches/1.1/lib/task/plugin/sfPluginInstallTask.class.php

    r6931 r7247  
    88 * file that was distributed with this source code. 
    99 */ 
     10 
     11require_once(dirname(__FILE__).'/sfPluginBaseTask.class.php'); 
    1012 
    1113/** 
  • branches/1.1/lib/task/plugin/sfPluginListTask.class.php

    r6931 r7247  
    88 * file that was distributed with this source code. 
    99 */ 
     10 
     11require_once(dirname(__FILE__).'/sfPluginBaseTask.class.php'); 
    1012 
    1113/** 
  • branches/1.1/lib/task/plugin/sfPluginUninstallTask.class.php

    r6931 r7247  
    88 * file that was distributed with this source code. 
    99 */ 
     10 
     11require_once(dirname(__FILE__).'/sfPluginBaseTask.class.php'); 
    1012 
    1113/** 
  • branches/1.1/lib/task/plugin/sfPluginUpgradeTask.class.php

    r6931 r7247  
    88 * file that was distributed with this source code. 
    99 */ 
     10 
     11require_once(dirname(__FILE__).'/sfPluginBaseTask.class.php'); 
    1012 
    1113/** 
  • branches/1.1/lib/util/sfCore.class.php

    r7243 r7247  
    119119  static public function initConfiguration($sf_symfony_lib_dir, $sf_symfony_data_dir, $test = false) 
    120120  { 
    121     require_once($sf_symfony_lib_dir.'/util/sfCoreAutoload.class.php'); 
     121    require_once($sf_symfony_lib_dir.'/autoload/sfCoreAutoload.class.php'); 
    122122    sfCoreAutoload::getInstance()->register(); 
    123123 
  • branches/1.1/test/bin/prove.php

    r7243 r7247  
    2828 
    2929$h->base_dir = realpath(dirname(__FILE__).'/..'); 
    30 require_once(dirname(__FILE__).'/../../lib/util/sfSimpleAutoload.class.php'); 
     30require_once(dirname(__FILE__).'/../../lib/autoload/sfSimpleAutoload.class.php'); 
    3131require_once(dirname(__FILE__).'/../../lib/util/sfToolkit.class.php'); 
    3232$autoload = sfSimpleAutoload::getInstance(sfToolkit::getTmpDir().DIRECTORY_SEPARATOR.sprintf('sf_autoload_unit_%s.data', md5(__FILE__))); 
     
    3434 
    3535// update sfCoreAutoload 
    36 require_once(dirname(__FILE__).'/../../lib/util/sfCoreAutoload.class.php'); 
     36require_once(dirname(__FILE__).'/../../lib/autoload/sfCoreAutoload.class.php'); 
    3737sfCoreAutoload::make(); 
    3838 
  • branches/1.1/test/bootstrap/unit.php

    r6870 r7247  
    2323sfConfig::set('sf_symfony_data_dir', realpath($_test_dir.'/../data')); 
    2424 
    25 require_once(dirname(__FILE__).'/../../lib/util/sfSimpleAutoload.class.php'); 
     25require_once(dirname(__FILE__).'/../../lib/autoload/sfSimpleAutoload.class.php'); 
    2626require_once(dirname(__FILE__).'/../../lib/util/sfToolkit.class.php'); 
    2727$autoload = sfSimpleAutoload::getInstance(sfToolkit::getTmpDir().DIRECTORY_SEPARATOR.sprintf('sf_autoload_unit_%s.data', md5(__FILE__)));