public function ImportConfigManipulator::getImportProcessorsByStage in Entity Share 8.3
Loads this import config's processors for a specific stage.
Parameters
\Drupal\entity_share_client\Entity\ImportConfigInterface $import_config: The import config.
string $stage: The stage for which to return the processors. One of the \Drupal\entity_share_client\ImportProcessor\ ImportProcessorInterface::STAGE_* constants.
array[] $overrides: (optional) Overrides to apply to the import config's processors, keyed by processor IDs with their respective overridden settings as values.
Return value
\Drupal\entity_share_client\ImportProcessor\ImportProcessorInterface[] An array of all enabled processors that support the given stage, ordered by the weight for that stage.
Overrides ImportConfigManipulatorInterface::getImportProcessorsByStage
1 call to ImportConfigManipulator::getImportProcessorsByStage()
- ImportConfigManipulator::getImportProcessorsByStages in modules/
entity_share_client/ src/ Service/ ImportConfigManipulator.php - Loads this import config's processors for a specific stage.
File
- modules/
entity_share_client/ src/ Service/ ImportConfigManipulator.php, line 131
Class
- ImportConfigManipulator
- Class ImportConfigManipulator.
Namespace
Drupal\entity_share_client\ServiceCode
public function getImportProcessorsByStage(ImportConfigInterface $import_config, $stage, array $overrides = []) {
// Get a list of all import processors which support this stage, along with
// their weights.
$processors = $this
->getImportProcessors($import_config);
$processor_weights = [];
foreach ($processors as $name => $processor) {
if ($processor
->supportsStage($stage)) {
$processor_weights[$name] = $processor
->getWeight($stage);
}
}
// Apply any overrides that were passed by the caller.
foreach ($overrides as $name => $config) {
$processor = $this->importProcessorPluginManager
->createInstance($name, $config);
if ($processor
->supportsStage($stage)) {
$processors[$name] = $processor;
$processor_weights[$name] = $processor
->getWeight($stage);
}
else {
// In rare cases, the override might change whether or not the import
// processor supports the given stage. So, to make sure, unset the
// weight in case it was set before.
unset($processor_weights[$name]);
}
}
// Sort requested import processors by weight.
asort($processor_weights);
$return_processors = [];
foreach (array_keys($processor_weights) as $name) {
$return_processors[$name] = $processors[$name];
}
return $return_processors;
}