2010-09-15 33 views
1

在symfony中,默認插件文件夾是/ plugin,我想知道是否有一種方法可以使用多個文件夾對不同類型的插件進行分類?是否可以在symfony中使用兩個不同的插件文件夾?

有一個sf_plugin_dir,但我不知道,可以配置爲一個數組,像

array(
    '/plugin-folder1/..', 
    '/plugin-folder2/..', 
) 

,並仍保持一切工作?像插件:發佈資產任務。

任何想法?

+0

你想這麼做的原因是什麼? – Timo 2010-09-15 10:32:15

回答

0

你會發現這裏的解決方案:http://gist.github.com/572781

讓我在這裏複製爲方便和將來參考:

class ProjectConfiguration extends sfProjectConfiguration 
{ 
    public function setup() 
    { 
    $this->setupProjectPlugins(); 
    } 

    /** 
    * Responsible for initiating any plugins and pointing vendor plugins 
    * to the "vendor" subdirectory 
    */ 
    protected function setupProjectPlugins() 
    { 
    $this->enableAllPluginsExcept(array('sfPropelPlugin')); 

    $vendorPlugins = array(
     'ioMenuPlugin', 
     'sfCKEditorPlugin', 
     'vjCommentPlugin', 
     'sfThemePlugin', 
     'sfDoctrineSlotPlugin', 
     'sfFormExtraPlugin', 
     'sfFeed2Plugin', 
     'sfImageTransformPlugin', 
     'sfDoctrineGuardPlugin', 
     'isicsBreadcrumbsPlugin', 
     'sfDoctrineActAsTaggablePlugin', 
     'sfInlineObjectPlugin', 
     'ioEditableContentPlugin', 
    ); 

    foreach ($vendorPlugins as $plugin) 
    { 
     $this->setPluginPath($plugin, sfConfig::get('sf_plugins_dir').'/vendor/'.$plugin); 
    } 
    $this->enablePlugins($vendorPlugins); 
    } 
} 
0

我有另一種解決方案,它不需要你保持的列表插件:

在ProjectConfiguration.class.php

public function getAllPluginPaths() 
{ 
    $pluginPaths = array(); 

    // search for *Plugin directories representing plugins 
    // follow links and do not recurse. No need to exclude VC because they do not end with *Plugin 
    $finder = sfFinder::type('dir')->maxdepth(0)->ignore_version_control(false)->follow_link()->name('*Plugin'); 
    $dirs = array(
    $this->getSymfonyLibDir().'/plugins', 
    'path/to/some/other/dir/plugins', # add path to your dir here. 
    sfConfig::get('sf_plugins_dir'), 
); 

    foreach ($finder->in($dirs) as $path) 
    { 
    $pluginPaths[basename($path)] = $path; 
    } 

    foreach ($this->overriddenPluginPaths as $plugin => $path) 
    { 
    $pluginPaths[$plugin] = $path; 
    } 

    return $pluginPaths; 
} 

(這是對symfony核心中的方法的輕微修改)

相關問題