You are here

protected function ConfigActionsValidateTrait::validatePath in Config Actions 8

Perform validation of the path. Call this from the plugin transform or execute method. Throws exception if validation fails.

Parameters

array $source:

4 calls to ConfigActionsValidateTrait::validatePath()
ConfigActionsAdd::transform in src/Plugin/ConfigActions/ConfigActionsAdd.php
Main transform to perform the add
ConfigActionsChange::transform in src/Plugin/ConfigActions/ConfigActionsChange.php
Main transform to perform the change
ConfigActionsDefault::transform in src/Plugin/ConfigActions/ConfigActionsDefault.php
Main transform to perform the change
ConfigActionsDelete::transform in src/Plugin/ConfigActions/ConfigActionsDelete.php
Main transform to perform the deletion

File

src/ConfigActionsValidateTrait.php, line 36

Class

ConfigActionsValidateTrait
Trait for adding options to perform path validation for a plugin.

Namespace

Drupal\config_actions

Code

protected function validatePath(array $source) {
  if (!is_null($this->current_value)) {
    $path = !empty($this->value_path) ? $this->value_path : $this->path;
    $actual_value = ConfigActionsTransform::read($source, $path);
    if ($actual_value !== $this->current_value) {
      throw new \Exception('Failed to validate path value for config action.');
    }
  }
}