Problem/Motivation

 * Classes for configurable plugins are a special case. They can either declare
 * their configuration dependencies using the calculateDependencies() method
 * described in the paragraph above, or if they have only static dependencies,
 * these can be declared using the 'config_dependencies' annotation key.

This is does not really tell the whole story. The configuration entity has to implement EntityWithPluginCollectionInterface and the plugins can implement ConfigurablePluginInterface. If the config entity implements EntityWithPluginCollectionInterface plugin providers and dependencies declared in the plugin's config_dependencies definition key (this does not have to be an annotation - it can be a derived definition) are added. If the plugin implements ConfigurablePluginInterface then each plugin instance's calculateDependencies() method is called.

Steps to reproduce

Proposed resolution

See #4

Remaining tasks

Review
Commit

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-2360647

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

alexpott’s picture

Status: Active » Needs review
StatusFileSize
new2.5 KB

First effort to improve this.

jhodgdon’s picture

Ummm... How does implementing an interface "automatically" do anything?

+ ... In
+ * order to use the generic functionality for plugin dependencies, configuration
+ * entity classes need to implement
+ * \Drupal\Core\Entity\EntityWithPluginCollectionInterface. This will
+ * automatically add the plugin's provider and dependencies declared in the
+ * "config_dependencies" key from the plugin's definition.
....
+ * In order to use the generic functionality for third party settings,
+ * configuration entity classes need to implement
+ * \Drupal\Core\Config\Entity\ThirdPartySettingsInterface.

The rest looks reasonable; not sure if accurate or not.

alexpott’s picture

Here's how (from ConfigEntityBase::calculateDependencies())

    if ($this instanceof EntityWithPluginCollectionInterface) {
      // Configuration entities need to depend on the providers of any plugins
      // that they store the configuration for.
      foreach ($this->getPluginCollections() as $plugin_collection) {
        foreach ($plugin_collection as $instance) {
          $this->calculatePluginDependencies($instance);
        }
      }
    }
jhodgdon’s picture

Ah. How about something like this then:

Some configuration entities have dependencies from plugins and third-party settings; these dependencies can be collected by \Drupal\Core\Config\Entity\ConfigEntityBase::calculateDependencies(). Entities with third-party settings need to implement \Drupal\Core\Config\Entity\ThirdPartySettingsInterface in order to trigger this generic dependency collection. Entities with plugin dependencies need to implement \Drupal\Core\Entity\EntityWithPluginCollectionInterface; this causes the base calculateDependencies() method to add the plugins' providers as dependencies, as well as dependencies declared in the "config_dependencies" key from the plugins' definitions. In addition, plugins that implement \Drupal\Component\Plugin\ConfigurablePluginInterface can declare additional dependencies using \Drupal\Component\Plugin\ConfigurablePluginInterface::calculateDependencies(), and these will also be collected by the base method.

jhedstrom’s picture

Status: Needs review » Needs work

CNW based on #4.

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.

mile23’s picture

Issue tags: +Needs reroll
$ git apply 2360647.1.patch 
error: patch failed: core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php:113
error: core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php: patch does not apply

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.

manuel garcia’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new2.49 KB

Patch was 2 years old, so It may no longer even make sense but well here it is rerolled.

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.

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

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

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

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
quietone’s picture

Status: Needs review » Needs work
Issue tags: +Bug Smash Initiative

@Manuel Garcia, thank you for rerolling the patch. Did you see the comment in #5 that set this to needs work for comment #4. In other words, this needs more that a reroll.

I read the text of the patch and the suggestion in #4. I think #4 is easier to read and understand. Let's use that.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Version: 9.5.x-dev » 11.x-dev
Issue summary: View changes
Issue tags: +Novice

Add novice tag

sourabhjain’s picture

Status: Needs work » Needs review
StatusFileSize
new2.39 KB
new2.59 KB

I have updated the changes mentioned in #4. Please review.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

#4 does appear to have been copied over.

RTBC+1

quietone’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: -Novice

I'm triaging RTBC issues. I re-read the IS and the comments.

My comment in #18 was a simple read of the suggested text, I did not check it for accuracy. In hindsight, that looks like a mistake.

It is a 9 year old comment and it does need to read and checked for accuracy. I did a bit of that by searching for each interface or method referred to in the comment. It turns out that \Drupal\Component\Plugin\ConfigurablePluginInterface no longer exists. It was removed in #3081145: Remove BC layers in the Plugin component.

Setting back to Needs work and removing the novice tag.

quietone’s picture

Title: Documentation in ConfigDependencyManager conflates plugin dependencies and config dependencies making it confusing » Documentation in ConfigDependencyManager conflates plugin dependencies and config dependencies
Issue summary: View changes
Status: Needs work » Needs review

Converted to MR and updated the text for a removed interface.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

"Entities with plugin dependencies need to" went right up to that 80 character line haha

Update seems good to me

  • catch committed cce51ccf on 10.3.x
    Issue #2360647 by quietone, alexpott, Manuel Garcia, jhodgdon:...

  • catch committed d8a66339 on 10.4.x
    Issue #2360647 by quietone, alexpott, Manuel Garcia, jhodgdon:...

  • catch committed 99b53d92 on 11.0.x
    Issue #2360647 by quietone, alexpott, Manuel Garcia, jhodgdon:...

  • catch committed 3219336f on 11.x
    Issue #2360647 by quietone, alexpott, Manuel Garcia, jhodgdon:...
catch’s picture

Version: 11.x-dev » 10.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 11.x and cherry-picked back through to 10.3.x, thanks!

Status: Fixed » Closed (fixed)

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