Comments

tim.plunkett created an issue. See original summary.

tim.plunkett’s picture

Status: Active » Needs review
StatusFileSize
new4.39 KB
eclipsegc’s picture

Status: Needs review » Needs work

After a bit of thinking and discussion this seems great. My only reservation at this point is that we need test coverage for the setDeriver method.

Eclipse

tim.plunkett’s picture

Status: Needs work » Postponed
StatusFileSize
new8.13 KB

We should resolve the approach in #2818653: Allow object-based plugin definitions to be processed in DefaultPluginManager::findDefinitions() before doing this, since they both expand PluginDefinitionInterface and should do it the same way.
Here's an updated patch with the new approach.

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

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now 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.

tim.plunkett’s picture

Version: 8.4.x-dev » 8.3.x-dev
Status: Postponed » Needs review
StatusFileSize
new9.85 KB

That went in, here's a new patch.
Ideally we'd finish expanding PDI all in one version.

wrt #3, I don't think the getter and setter need explicit test coverage, there is no logic in those.

tstoeckler’s picture

Re #6: I personally don't necessarily agree with that standard, but we do generally test getters and setters. You can test both of them neatly in one test method. Don't feel strongly about this, though.

My main reservation about this, is why this is not a dedicated interface. Not all plugin definitions are necessarily derivable, so it seems sensible to keep the current separation of providing a separate DerivablePluginDefinitionInterface.

Status: Needs review » Needs work

The last submitted patch, 6: 2821189-pdi-6.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new5.84 KB
new7.9 KB

Okay, I agree, and double checked with @EclipseGc who also prefers a separate interface. I think #4 was just a mistake on my part.
Interdiff against #2

Status: Needs review » Needs work

The last submitted patch, 9: 2821189-deriver-9.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new507 bytes
new8.39 KB

Missed a spot

jibran’s picture

Status: Needs review » Reviewed & tested by the community
similarity index 58%
rename from core/lib/Drupal/Core/Layout/DerivablePluginDefinitionInterface.php

rename from core/lib/Drupal/Core/Layout/DerivablePluginDefinitionInterface.php
rename to core/lib/Drupal/Component/Plugin/Definition/DerivablePluginDefinitionInterface.php

It was marked internal so moving it is not a problem. We have a new test which is always great.

The last submitted patch, 4: 2821189-deriver-4.patch, failed testing.

tstoeckler’s picture

Thanks for the quick follow-up, RTBC++!

xjm’s picture

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

Note that issues like this should be targeted against 8.4.x, but can be considered for backport once they are committed to that branch. See the updated alpha release policy. Thanks!

tim.plunkett’s picture

effulgentsia’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/lib/Drupal/Component/Plugin/Definition/DerivablePluginDefinitionInterface.php
    @@ -1,22 +1,11 @@
     interface DerivablePluginDefinitionInterface extends PluginDefinitionInterface {
    

    Although this is just a code move, it's a move from an @internal to not, so I think this is the time to ask if we should change DerivablePluginDefinitionInterface to not extend PluginDefinitionInterface. Note that DependentPluginDefinitionInterface in HEAD does not extend PluginDefinitionInterface.

  2. +++ b/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php
    @@ -203,7 +204,13 @@ protected function getDeriver($base_plugin_id, $base_definition) {
    -    if ((is_array($base_definition) || ($base_definition = (array) $base_definition)) && (isset($base_definition['deriver']) && $class = $base_definition['deriver'])) {
    ...
    +    if ($class) {
           if (!class_exists($class)) {
             throw new InvalidDeriverException(sprintf('Plugin (%s) deriver "%s" does not exist.', $base_definition['id'], $class));
    

    That throw, along with the one a couple lines down so not in the diff, can now run for an object-based $base_definition, so we need to s/$base_definition['id']/$base_definition->id()/ as well. Which is maybe a reason to keep DerivablePluginDefinitionInterface as extending PluginDefinitionInterface? Though if we decide to do that, then perhaps we need a followup to make DependentPluginDefinitionInterface also extend that interface? I don't think it makes sense for those two to follow different patterns.

  3. This issue is tagged "Contributed project soft blocker". Which contrib projects are soft blocked? Why can't they just make their 'deriver' property public, in which case, wouldn't HEAD work due to that it's already casting to an array?
tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new10.05 KB
new3.39 KB

#17

1) Core has both of these patterns and it is very confusing. For example:
interface PluginWithFormsInterface extends PluginInspectionInterface {
vs
interface PluginFormInterface {
Because of the second point of your review, I think it's necessary and correct to have it extend PluginDefinitionInterface.
I will open a follow-up for DependentPluginDefinitionInterface

2) Nice catch! Fixed and added test coverage

3) I don't recall which project it was in particular, but as object-based plugin definitions catch on, this will absolutely become a problem.

Status: Needs review » Needs work

The last submitted patch, 18: 2821189-deriver-18.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new6.71 KB
new15.97 KB

Before, we only used the ID during the exception, so our test fixtures omitted it. But an ID is a required part of a plugin definition, so the tests were just cheating.

tim.plunkett’s picture

effulgentsia’s picture

Status: Needs review » Reviewed & tested by the community

The interdiffs since the last RTBC patch are all straightforward, so I feel ok with RTBC'ing this and remaining eligible to commit this.

effulgentsia’s picture

Adding review credit for #7.

  • effulgentsia committed 7f3c710 on 8.4.x
    Issue #2821189 by tim.plunkett, tstoeckler: Allow object-based plugin...

  • effulgentsia committed b7d04d6 on 8.3.x
    Issue #2821189 by tim.plunkett, tstoeckler: Allow object-based plugin...
effulgentsia’s picture

Version: 8.4.x-dev » 8.3.x-dev
Status: Reviewed & tested by the community » Fixed

I'm ok with #18.1 and thanks for the fixes and tests for #18.2. Therefore, pushed to 8.4.x.

I'm not super convinced by #18.3, but as this is the last of the outstanding object-based definition issues, and the others all made their way into 8.3, I decided to cherry pick this one to 8.3 as well. In #2822752-22: Allow object-based plugin definitions to be created by non-annotated discovery, I proposed creating a single CR to cover all the object-based definition discovery improvements, so this being part of that is nice.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.