You are here

public static function ConfigActionsTransform::replace in Config Actions 8

Replace tokens within yaml data and return the resulting array

Parameters

mixed $item: $item can be a string of yml data to be processed if $item is an array, each element is processed

array $replacements: key/value array with search/replace strings.

array $key_replacements: optional key/value array with search/replace strings for item keys.

Return value

mixed

5 calls to ConfigActionsTransform::replace()
ConfigActionsPluginBase::parseOptions in src/ConfigActionsPluginBase.php
Parse any property references in the options.
ConfigActionsPluginBase::replaceData in src/ConfigActionsPluginBase.php
Perform string replacement on the $data and return the result.
ConfigActionsPluginTest::testInclude in tests/src/Kernel/ConfigActionsPluginTest.php
@covers \Drupal\config_actions\Plugin\ConfigActions\ConfigActionsInclude
ConfigActionsPluginTest::testTemplate in tests/src/Kernel/ConfigActionsPluginTest.php
@covers \Drupal\config_actions\Plugin\ConfigActions\ConfigActionsChange
ConfigActionsTransformTest::testReplace in tests/src/Unit/ConfigActionsTransformTest.php
@covers ::replace

File

src/ConfigActionsTransform.php, line 151

Class

ConfigActionsTransform
Perform transformations on data needed for config_actions plugins

Namespace

Drupal\config_actions

Code

public static function replace($item, array $replacements, array $key_replacements = []) {
  $tree = static::replaceTree($item, array_keys($replacements), array_values($replacements), array_keys($key_replacements), array_values($key_replacements));
  if (is_string($tree) && !is_string($item)) {
    $tree = Yaml::decode($tree);
  }
  return $tree;
}