You are here

public function MgvPluginManager::getNamespacedValue in More Global Variables 8

Create namespaced value of given global variable id and instance.

Parameters

string $plugin_id: Plugin id.

\Drupal\mgv\Plugin\GlobalVariableInterface $variable: Plugin instance.

Return value

array|mixed Generated value.

Overrides MgvPluginManagerInterface::getNamespacedValue

1 call to MgvPluginManager::getNamespacedValue()
MgvPluginManager::getVariables in src/MgvPluginManager.php
Returns all the variables.

File

src/MgvPluginManager.php, line 80

Class

MgvPluginManager
Class MgvPluginManager.

Namespace

Drupal\mgv

Code

public function getNamespacedValue($plugin_id, GlobalVariableInterface $variable) {
  $value = $variable
    ->getValue();
  $namespaces = explode('\\', $plugin_id);
  foreach (array_reverse($namespaces) as $name) {
    $value = [
      $name => $value,
    ];
  }
  return $value;
}