Follow-up to #1937600: Determine what services to register in the new Drupal class

We need to decide what we want to do with plugin managers, some of them are quite frequently accessed.

My suggestion:

1. Enforce the naming pattern that afaik all or most are already using, which is plugin.manager.$something
2. Add a Drupal::pluginManager($something)
3. For those that are accessed very frequently and provide custom methods, e.g. entityManager(), add a specific method so that we have type hints for the additional methods.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yched’s picture

Drupal::pluginManager($something), with $something = 'tour.tip' or 'views.field', i.e "a substring of a service id string" looks a bit odd DX wise.
Maybe Drupal::pluginManager($owner, $type) ?

+1 on Drupal::entityManager()

xjm’s picture

Yeah, I agree with #1 I think. Having two args would be way better DX. And I also think the explicit entityManager() is a good idea.

Berdir’s picture

Two arguments shoulds fine to me, maps to how plugin implementations are defined. Do we want any special casing for those where it's the same, e.g. Drupal::pluginManager('block', 'block') is a bit silly, but so is Plugin\block\block\MyBlock.

I guess that means we will have to rename a few service names so that we can map the arguments to a service name...

yched’s picture

I'd say Drupal::pluginManager('block', 'block') is fine. Consistency++, IMO.

Berdir’s picture

Looks like the entityManager() already happened in #1982984: Create Drupal::entityManager for improved DX, so this just needs pluginManager().

Berdir’s picture

Status: Active » Needs review
FileSize
46.98 KB

Something like this..

There are some special cases, e.g. the layout_manager() that we could remove here and Views which already has Views::pluginManager(), not sure if we want to keep that?

Also added support for the service name plugin.manager.$owner where $owner == $type. Not sure if we want to support this.

In fact, I feel like we should discourage $owner == $type, it is IMHO more confusing to understand.

Renamed the rest resource.

tim.plunkett’s picture

#1966246: [meta] Introduce specific annotations for each plugin type has a table with $owner and $type for each one, it shows a great deal of inconsistency.

Status: Needs review » Needs work

The last submitted patch, drupal-plugin-manager-1950670-6.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
544 bytes
47.29 KB

This should fix the tests.

Not yet sure what to do with the core plugin managers (constraint, condition, archiver), as the are quite a mess in regards to naming. We could leave them out for now. It just means that pluginManager() doesn't work for them, which can be fixed/moved in separate issues.

damiankloip’s picture

FileSize
46.47 KB

Rerolled.

How about we use an optional second parameter and go with logic like:

if (isset($param2)) {
  $manager .= ".$param2";
}

?

Berdir’s picture

I guess now that the plugin directory was simplified to a single argument, we should also go back to a single argument here I think.

dawehner’s picture

Status: Needs review » Needs work

This needs also a rerole.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Berdir’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)

Doesn't look like there is a need for this.