When the plugin system first went in, we converted aggregator.module as an example, and decided that the FetcherManager class should be in Drupal\aggregator\Plugin\FetcherManager, not Drupal\aggregator\Plugin\Type\FetcherManager.

Views currently has some manager classes in Drupal\views\Plugin\Type\, but in other issues, tim.plunkett indicated a willingness to move them up a level.

Field currently provides several supporting classes for formatters and widgets, and so provides a subnamespace for each: Drupal\field\Plugin\Type\Formatter\* and Drupal\field\Plugin\Type\Widget\*.

Do we want to standardize on whether to:
- always use Type,
- never use Type,
- or only use Type when wanting to have subnamespaces within it?

Comments

Title:Should any/some/all plugin manager classes live in a Type subnamespace?Move plugin manager classes out of \Type sub-namespace

Yeah, this is terribly confusing.

Let's move them out of the \Type subnamespace.

How should we handle the field.module case, where multiple types are provided, and each one comes with enough supporting classes in addition to the manager to warrant separate directories?

I'm concerned about having Drupal\field\Plugin\Formatter\FormatterPluginManager, because of possible confusion with the other convention that plugins (rather than plugin managers) live in subnamespaces of Plugin.

I wonder if for plugin managers, interfaces, custom factories, etc., if we want to drop the Plugin part entirely, and just have Drupal\field\Formatter\FormatterPluginManager, reserving the Plugin subnamespace for the plugins themselves only.

Note that some modules put the manager class in the Drupal\moduleName namespace too. I.e. there are essentially three cases, not two:

  1. Drupal\moduleName (e.g. ban.module)
  2. Drupal\moduleName\Plugin (e.g. edit.module)
  3. Drupal\moduleName\Plugin\Type (e.g. block.module)

I wonder if for plugin managers, interfaces, custom factories, etc., if we want to drop the Plugin part entirely, and just have Drupal\field\Formatter\FormatterPluginManager, reserving the Plugin subnamespace for the plugins themselves only.

+1

I was going to post exactly that here. Then the purpose is of that directory is always clear, and it's very clear where you look for plugin implementations. Everything else sits at Drupal\moduleName then.

Yeah, sorry, I thought of exactly the same.

That is, however, *cough*, only unless #1847002: Move entity type classes from Drupal\$provider\Plugin\Core\Entity to Drupal\$provider\Entity won't happen full-frontal. If that issue will happen in its entirety, then the actual plugin type implementations will be relocated like this:

- Drupal\foo\Plugin\pluginOwner\pluginType\FooPlugin
+ Drupal\foo\pluginOwner\pluginType\FooPlugin

In turn, that opens up the \Plugin namespace of its own. And alas, plugin managers are integrating with the Plugin service, so they should be located accordingly.

As a result, there are two possible directions here, depending on aforementioned issue:

- Current:       Drupal\foo\Plugin\Type\FooPluginManager
+ w/o #1847002:  Drupal\foo\FooPluginManager
+ w/  #1847002:  Drupal\foo\Plugin\FooPluginManager

For now, I'd recommend to simply move them out of \Type. So much is clear.