You are here

public function ConfigActionsService::saveSource in Config Actions 8

Save data from a given source plugin.

Parameters

mixed $data to be saved:

mixed $dest specifier:

string $type: source plugin id

string $base: optional base path

bool $force: True if data should be saved regardless of pipeline

Return value

bool True if plugin could save data

Overrides ConfigActionsServiceInterface::saveSource

File

src/ConfigActionsService.php, line 208

Class

ConfigActionsService
Base class for config_actions plugins.

Namespace

Drupal\config_actions

Code

public function saveSource($data, $dest, $type = '', $base = '', $force = FALSE) {
  $result = FALSE;
  if (!empty($dest)) {
    $plugin = $this
      ->getSourcePlugin($dest, $type, $base);
    if (!empty($plugin)) {

      // Check if source data required merging.
      $plugin
        ->setMerge($plugin
        ->getMerge() || $this->merge);
      if ($force) {
        $result = $plugin
          ->save($data);
      }
      else {
        $plugin
          ->setData($data);
        $result = TRUE;
      }
    }
  }
  return $result;
}