Error message

  • Warning: count(): Parameter must be an array or an object that implements Countable in _api_make_match_member_link() (line 1230 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Warning: count(): Parameter must be an array or an object that implements Countable in _api_make_match_member_link() (line 1230 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).

public function ConfigSource::getData

Implements TMGMTEntitySourcePluginController::getData().

Returns the data from the fields as a structure that can be processed by the Translation Management system.

Overrides SourcePluginInterface::getData

File

sources/tmgmt_config/src/Plugin/tmgmt/Source/ConfigSource.php, line 205

Class

ConfigSource
Content entity source plugin controller.

Namespace

Drupal\tmgmt_config\Plugin\tmgmt\Source

Code

public function getData(JobItemInterface $job_item) {
  $config_mapper = $this
    ->getMapper($job_item);
  $data = array();
  foreach ($config_mapper
    ->getConfigData() as $config_id => $config_data) {
    $schema = $this->typedConfig
      ->get($config_id);
    $processor = $this
      ->getConfigProcessor($schema);
    $processor
      ->setConfigMapper($config_mapper);
    $config_id = str_replace('.', '__', $config_id);
    $data[$config_id] = $processor
      ->extractTranslatables($schema, $config_data);
  }

  // If there is only one, we simplify the data and return it.
  if (count($data) == 1) {
    return reset($data);
  }
  else {
    return $data;
  }
}