Development

Changeset 20053

You must first sign up to be able to contribute.

Changeset 20053

Show
Ignore:
Timestamp:
07/09/09 14:49:20 (4 years ago)
Author:
nicolas
Message:

[1.1, 1.2, 1.3] fixed autoload order, enhanced performances of tasks autoloading

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/lib/command/sfSymfonyCommandApplication.class.php

    r20049 r20053  
    1919class sfSymfonyCommandApplication extends sfCommandApplication 
    2020{ 
    21   protected $taskDirs = array(); 
     21  protected $taskFiles = array(); 
    2222   
    2323  /** 
     
    9191  { 
    9292    // Symfony core tasks 
    93     $this->taskDirs = array(sfConfig::get('sf_symfony_lib_dir').'/task'); 
     93    $dirs = array(sfConfig::get('sf_symfony_lib_dir').'/task'); 
    9494 
    9595    // Plugin tasks 
     
    9898      if (is_dir($taskPath = $path.'/lib/task')) 
    9999      { 
    100         $this->taskDirs[] = $taskPath; 
     100        $dirs[] = $taskPath; 
    101101      } 
    102102    } 
    103103 
    104104    // project tasks 
    105     $this->taskDirs[] = sfConfig::get('sf_lib_dir').'/task'; 
     105    $dirs[] = sfConfig::get('sf_lib_dir').'/task'; 
    106106 
    107     // require tasks 
    108107    $finder = sfFinder::type('file')->name('*Task.class.php'); 
     108    foreach ($finder->in($dirs) as $file) 
     109    { 
     110      $this->taskFiles[basename($file, '.class.php')] = $file; 
     111    } 
    109112 
    110113    // register local autoloader for tasks 
    111114    spl_autoload_register(array($this, 'autoloadTask')); 
    112115 
    113     foreach ($finder->in($this->taskDirs) as $task) 
     116    // require tasks 
     117    foreach ($this->taskFiles as $task => $file) 
    114118    { 
    115119      // forces autoloading of each task class 
    116       class_exists(basename($task, '.class.php'), true); 
     120      class_exists($task, true); 
    117121    } 
    118122 
     
    130134  public function autoloadTask($class) 
    131135  { 
    132     foreach ($this->taskDirs as $dir
     136    if (isset($this->taskFiles[$class])
    133137    { 
    134       if (file_exists($file = $dir.'/'.$class.'.class.php')) 
    135       { 
    136         require_once $file; 
     138      require_once $this->taskFiles[$class]; 
    137139 
    138         return true; 
    139       } 
     140      return true; 
    140141    } 
    141142 
  • branches/1.2/lib/command/sfSymfonyCommandApplication.class.php

    r20049 r20053  
    1919class sfSymfonyCommandApplication extends sfCommandApplication 
    2020{ 
    21   protected $taskDirs = array(); 
     21  protected $taskFiles = array(); 
    2222   
    2323  /** 
     
    9191  { 
    9292    // Symfony core tasks 
    93     $this->taskDirs = array(sfConfig::get('sf_symfony_lib_dir').'/task'); 
     93    $dirs = array(sfConfig::get('sf_symfony_lib_dir').'/task'); 
    9494 
    9595    // Plugin tasks 
     
    9898      if (is_dir($taskPath = $path.'/lib/task')) 
    9999      { 
    100         $this->taskDirs[] = $taskPath; 
     100        $dirs[] = $taskPath; 
    101101      } 
    102102    } 
    103103 
    104104    // project tasks 
    105     $this->taskDirs[] = sfConfig::get('sf_lib_dir').'/task'; 
     105    $dirs[] = sfConfig::get('sf_lib_dir').'/task'; 
    106106 
    107     // require tasks 
    108107    $finder = sfFinder::type('file')->name('*Task.class.php'); 
     108    foreach ($finder->in($dirs) as $file) 
     109    { 
     110      $this->taskFiles[basename($file, '.class.php')] = $file; 
     111    } 
    109112 
    110113    // register local autoloader for tasks 
    111114    spl_autoload_register(array($this, 'autoloadTask')); 
    112115 
    113     foreach ($finder->in($this->taskDirs) as $task) 
     116    // require tasks 
     117    foreach ($this->taskFiles as $task => $file) 
    114118    { 
    115119      // forces autoloading of each task class 
    116       class_exists(basename($task, '.class.php'), true); 
     120      class_exists($task, true); 
    117121    } 
    118122 
     
    130134  public function autoloadTask($class) 
    131135  { 
    132     foreach ($this->taskDirs as $dir
     136    if (isset($this->taskFiles[$class])
    133137    { 
    134       if (file_exists($file = $dir.'/'.$class.'.class.php')) 
    135       { 
    136         require_once $file; 
     138      require_once $this->taskFiles[$class]; 
    137139 
    138         return true; 
    139       } 
     140      return true; 
    140141    } 
    141142 
  • branches/1.3/lib/command/sfSymfonyCommandApplication.class.php

    r20049 r20053  
    1919class sfSymfonyCommandApplication extends sfCommandApplication 
    2020{ 
    21   protected $taskDirs = array(); 
     21  protected $taskFiles = array(); 
    2222   
    2323  /** 
     
    9191  { 
    9292    // Symfony core tasks 
    93     $this->taskDirs = array(sfConfig::get('sf_symfony_lib_dir').'/task'); 
     93    $dirs = array(sfConfig::get('sf_symfony_lib_dir').'/task'); 
    9494 
    9595    // Plugin tasks 
     
    9898      if (is_dir($taskPath = $path.'/lib/task')) 
    9999      { 
    100         $this->taskDirs[] = $taskPath; 
     100        $dirs[] = $taskPath; 
    101101      } 
    102102    } 
    103103 
    104104    // project tasks 
    105     $this->taskDirs[] = sfConfig::get('sf_lib_dir').'/task'; 
     105    $dirs[] = sfConfig::get('sf_lib_dir').'/task'; 
    106106 
    107     // require tasks 
    108107    $finder = sfFinder::type('file')->name('*Task.class.php'); 
     108    foreach ($finder->in($dirs) as $file) 
     109    { 
     110      $this->taskFiles[basename($file, '.class.php')] = $file; 
     111    } 
    109112 
    110113    // register local autoloader for tasks 
    111114    spl_autoload_register(array($this, 'autoloadTask')); 
    112115 
    113     foreach ($finder->in($this->taskDirs) as $task) 
     116    // require tasks 
     117    foreach ($this->taskFiles as $task => $file) 
    114118    { 
    115119      // forces autoloading of each task class 
    116       class_exists(basename($task, '.class.php'), true); 
     120      class_exists($task, true); 
    117121    } 
    118122 
     
    130134  public function autoloadTask($class) 
    131135  { 
    132     foreach ($this->taskDirs as $dir
     136    if (isset($this->taskFiles[$class])
    133137    { 
    134       if (file_exists($file = $dir.'/'.$class.'.class.php')) 
    135       { 
    136         require_once $file; 
     138      require_once $this->taskFiles[$class]; 
    137139 
    138         return true; 
    139       } 
     140      return true; 
    140141    } 
    141142