views:

21

answers:

2

In symfony the default plugin folder is /plugin, I'm wondering if there is a way to use more than one folder to categorize different types of plugins?

There is a sf_plugin_dir but I'm not sure that can be configured to be an array, something like

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

and still keeps everything working? Like the plugin:publish-assets task.

Any ideas?

A: 

You'll find the solution here: http://gist.github.com/572781

Let me copy it here for convenience and future reference:

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);
  }
}
kuba
A: 

I have another solution, which doesn't require you maintain the list of plugins:

In 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;
}

(this is a slight mod to the method found in the symfony core)

benlumley