You are here

public function ConfigPagesType::getContextData in Config Pages 8

Same name and namespace in other branches
  1. 8.3 src/Entity/ConfigPagesType.php \Drupal\config_pages\Entity\ConfigPagesType::getContextData()
  2. 8.2 src/Entity/ConfigPagesType.php \Drupal\config_pages\Entity\ConfigPagesType::getContextData()

Provides the serialized context data.

Return value

string

File

src/Entity/ConfigPagesType.php, line 88

Class

ConfigPagesType
Defines the config page type entity.

Namespace

Drupal\config_pages\Entity

Code

public function getContextData() {
  $contextData = [];
  if (!empty($this->context['group'])) {
    foreach ($this->context['group'] as $context_id => $context_enabled) {
      if ($context_enabled) {

        // @to_do: Refactor static load.
        $item = \Drupal::service('plugin.manager.config_pages_context')
          ->getDefinition($context_id);
        $context_value = $item['class']::getValue();
        $contextData[] = [
          $context_id => $context_value,
        ];
      }
    }
  }
  return serialize($contextData);
}