Chris@0: $instance_config) { Chris@0: $default_config = []; Chris@0: $default_config['id'] = $instance_id; Chris@0: $default_config += $this->get($instance_id)->defaultConfiguration(); Chris@0: // In order to determine if a plugin is configured, we must compare it to Chris@0: // its default configuration. The default configuration of a plugin does Chris@0: // not contain context_mapping and it is not used when the plugin is not Chris@0: // configured, so remove the context_mapping from the instance config to Chris@0: // compare the remaining values. Chris@0: unset($instance_config['context_mapping']); Chris@0: if ($default_config === $instance_config) { Chris@0: unset($configuration[$instance_id]); Chris@0: } Chris@0: } Chris@0: return $configuration; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Sets the condition context for a given name. Chris@0: * Chris@0: * @param string $name Chris@0: * The name of the context. Chris@0: * @param \Drupal\Component\Plugin\Context\ContextInterface $context Chris@0: * The context to add. Chris@0: * Chris@0: * @return $this Chris@0: */ Chris@0: public function addContext($name, ContextInterface $context) { Chris@0: $this->conditionContexts[$name] = $context; Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Gets the values for all defined contexts. Chris@0: * Chris@0: * @return \Drupal\Component\Plugin\Context\ContextInterface[] Chris@0: * An array of set contexts, keyed by context name. Chris@0: */ Chris@0: public function getConditionContexts() { Chris@0: return $this->conditionContexts; Chris@0: } Chris@0: Chris@0: }