From a2189aadc2408efb61debac788f1c4ef48d0a081 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Rene=CC=81e=20Beach?= Date: Wed, 16 Apr 2014 16:52:41 -0400 Subject: [PATCH] docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: J. ReneĢe Beach --- core/modules/system/core.api.php | 59 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/core/modules/system/core.api.php b/core/modules/system/core.api.php index 1ecc9c1..d16a958 100644 --- a/core/modules/system/core.api.php +++ b/core/modules/system/core.api.php @@ -120,6 +120,65 @@ * overview level. And link to more detailed documentation. * * See https://drupal.org/developing/api/entity + * + * @section config_dependencies Configuration Dependencies + * + * Dependencies are declared in a plugin's definition. A system menu block is an + * example from Drupal core that utilizes this pattern. The menu block declares a + * dependency on the menu's corresponding entity. The following code illustrates + * how this association is established through the following method: + * + * @code + * // Drupal\Core\Config\Entity\ConfigEntityBase::calculateDependencies + * public function calculateDependencies() { + * // Dependencies should be recalculated on every save. This ensures stale + * // dependencies are never saved. + * $this->dependencies = array(); + * if ($this instanceof EntityWithPluginBagInterface) { + * // Configuration entities need to depend on the providers of any plugins + * // that they store the configuration for. + * $plugin_bag = $this->getPluginBag(); + * foreach($plugin_bag as $instance) { + * $definition = $instance->getPluginDefinition(); + * $this->addDependency('module', $definition['provider']); + * // Plugins can declare additional dependencies in their definition. + * if (isset($definition['config_dependencies'])) { + * foreach ($definition['config_dependencies'] as $type => $dependencies) { + * foreach ($dependencies as $dependency) { + * $this->addDependency($type, $dependency); + * } + * } + * } + * } + * } + * return $this->dependencies; + * } + * @endcode + * + * The config_dependencies key in the plugins' definition is assigned an array of + * dependencies. The keys of this array may be one of: + * - entity + * - module + * - theme + * + * For example, the system menu block for the Bartik theme declares the following + * dependencies in its configuration definition file. + * + * @code + * // core/profiles/standard/config/block.block.bartik_footer.yml + * id: bartik_footer + * theme: bartik + * ... + * dependencies: + * entity: + * - system.menu.footer + * module: + * - system + * theme: + * - bartik + * @endcode + * + * @see https://drupal.org/documentation/administer/config * @} */ -- 1.8.5.3