Development

#3407: OverloadBundledPlugins.php.patch

You must first sign up to be able to contribute.

Ticket #3407: OverloadBundledPlugins.php.patch

File OverloadBundledPlugins.php.patch, 3.6 kB (added by Carl.Vondrick, 9 months ago)

possible patch

  • lib/command/sfSymfonyCommandApplication.class.php

    old new  
    3636    $this->setName('symfony'); 
    3737    $this->setVersion(SYMFONY_VERSION); 
    3838 
    39     $this->loadTasks(); 
     39    $this->loadTasks($configuration); 
    4040  } 
    4141 
    4242  /** 
     
    7373   * Loads all available tasks. 
    7474   * 
    7575   * Looks for tasks in the symfony core, the current project and all project plugins. 
     76   * 
     77   * @param sfProjectConfiguration The project configuration 
    7678   */ 
    77   protected function loadTasks(
     79  protected function loadTasks(sfProjectConfiguration $configuration
    7880  { 
    7981    $dirs = array( 
    8082      sfConfig::get('sf_symfony_lib_dir').'/task',               // symfony tasks 
    81       sfConfig::get('sf_symfony_lib_dir').'/plugins/*/lib/task', // bundled plugin tasks 
    82       sfConfig::get('sf_plugins_dir').'/*/lib/task',             // plugin tasks 
    8383      sfConfig::get('sf_lib_dir').'/task',                       // project tasks 
    8484    ); 
    8585    $finder = sfFinder::type('file')->name('*Task.class.php'); 
    8686 
    87     foreach ($dirs as $globDir
     87    foreach ($finder->in($dirs) as $task
    8888    { 
    89       if (!$dirs = glob($globDir)) 
    90       { 
    91         continue; 
    92       } 
     89      require_once $task; 
     90    } 
    9391 
    94       foreach ($finder->in($dirs) as $task) 
     92    foreach ($configuration->getPluginPaths() as $path) 
     93    { 
     94      $taskPath = $path.'/lib/task'; 
     95      if (is_dir($taskPath)) 
    9596      { 
    96         require_once $task; 
     97        foreach ($finder->in($taskPath) as $task) 
     98        { 
     99          require_once $task; 
     100        } 
    97101      } 
    98102    } 
    99103  } 
  • lib/config/sfProjectConfiguration.class.php

    old new  
    227227  } 
    228228 
    229229  /** 
     230   * Gets the paths to plugins root directories, minding overloaded plugins. 
     231   * 
     232   * @return array The plugin root paths. 
     233   */ 
     234  public function getPluginPaths() 
     235  { 
     236    $plugins = sfFinder::type('dir')->discard('.*')->prune('.*')->maxdepth(0)->in(sfConfig::get('sf_plugins_dir')); 
     237 
     238    $bundledPluginDir = sfConfig::get('sf_symfony_lib_dir').'/plugins'; 
     239    $bundledPlugins = sfFinder::type('dir')->maxdepth(0)->relative()->in($bundledPluginDir); 
     240    foreach ($bundledPlugins as $bundledPlugin) 
     241    { 
     242      if (!is_dir(sfConfig::get('sf_plugins_dir').'/'.$bundledPlugin)) 
     243      { 
     244        $plugins[] = $bundledPluginDir.'/'.$bundledPlugin; 
     245      } 
     246    } 
     247 
     248    return $plugins; 
     249  } 
     250 
     251  /** 
    230252   * Returns the event dispatcher. 
    231253   * 
    232254   * @return sfEventDispatcher A sfEventDispatcher instance 
  • lib/config/sfApplicationConfiguration.class.php

    old new  
    506506   */ 
    507507  public function loadPluginConfig() 
    508508  { 
    509     if ($pluginConfigs = glob(sfConfig::get('sf_symfony_lib_dir').'/plugins/*/config/config.php')
     509    foreach ($this->getPluginPaths() as $path
    510510    { 
    511       foreach ($pluginConfigs as $config) 
     511      $config = $path.'/config/config.php'; 
     512      if (is_readable($config)) 
    512513      { 
    513514        require $config; 
    514515      } 
    515516    } 
    516  
    517     if ($pluginConfigs = glob(sfConfig::get('sf_plugins_dir').'/*/config/config.php')) 
    518     { 
    519       foreach ($pluginConfigs as $config) 
    520       { 
    521         require $config; 
    522       } 
    523     } 
    524517  } 
    525518 
    526519  /**