comparison core/lib/Drupal/Core/Plugin/ContextAwarePluginBase.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents a9cd425dd02b
children
comparison
equal deleted inserted replaced
4:a9cd425dd02b 5:12f9dff5fda9
1 <?php 1 <?php
2 2
3 namespace Drupal\Core\Plugin; 3 namespace Drupal\Core\Plugin;
4 4
5 use Drupal\Component\Plugin\ConfigurablePluginInterface;
6 use Drupal\Component\Plugin\ContextAwarePluginBase as ComponentContextAwarePluginBase; 5 use Drupal\Component\Plugin\ContextAwarePluginBase as ComponentContextAwarePluginBase;
7 use Drupal\Component\Plugin\Exception\ContextException; 6 use Drupal\Component\Plugin\Exception\ContextException;
7 use Drupal\Component\Plugin\PluginHelper;
8 use Drupal\Core\Cache\Cache; 8 use Drupal\Core\Cache\Cache;
9 use Drupal\Core\Cache\CacheableDependencyInterface; 9 use Drupal\Core\Cache\CacheableDependencyInterface;
10 use Drupal\Core\DependencyInjection\DependencySerializationTrait; 10 use Drupal\Core\DependencyInjection\DependencySerializationTrait;
11 use Drupal\Core\Plugin\Context\Context; 11 use Drupal\Core\Plugin\Context\Context;
12 use Drupal\Core\StringTranslation\StringTranslationTrait; 12 use Drupal\Core\StringTranslation\StringTranslationTrait;
76 76
77 /** 77 /**
78 * {@inheritdoc} 78 * {@inheritdoc}
79 */ 79 */
80 public function getContextMapping() { 80 public function getContextMapping() {
81 $configuration = $this instanceof ConfigurablePluginInterface ? $this->getConfiguration() : $this->configuration; 81 $configuration = PluginHelper::isConfigurable($this) ? $this->getConfiguration() : $this->configuration;
82 return isset($configuration['context_mapping']) ? $configuration['context_mapping'] : []; 82 return isset($configuration['context_mapping']) ? $configuration['context_mapping'] : [];
83 } 83 }
84 84
85 /** 85 /**
86 * {@inheritdoc} 86 * {@inheritdoc}
87 */ 87 */
88 public function setContextMapping(array $context_mapping) { 88 public function setContextMapping(array $context_mapping) {
89 if ($this instanceof ConfigurablePluginInterface) { 89 if (PluginHelper::isConfigurable($this)) {
90 $configuration = $this->getConfiguration(); 90 $configuration = $this->getConfiguration();
91 $configuration['context_mapping'] = array_filter($context_mapping); 91 $configuration['context_mapping'] = array_filter($context_mapping);
92 $this->setConfiguration($configuration); 92 $this->setConfiguration($configuration);
93 } 93 }
94 else { 94 else {