protected function SalesforceMappingCommandsBase::getMappingsFromName in Salesforce Suite 5.0.x
Same name and namespace in other branches
- 8.4 modules/salesforce_mapping/src/Commands/SalesforceMappingCommandsBase.php \Drupal\salesforce_mapping\Commands\SalesforceMappingCommandsBase::getMappingsFromName()
- 8.3 modules/salesforce_mapping/src/Commands/SalesforceMappingCommandsBase.php \Drupal\salesforce_mapping\Commands\SalesforceMappingCommandsBase::getMappingsFromName()
Given a mapping name (and optional direction), get an array of mappings.
Parameters
string $name: 'ALL' to load all mappings, or a mapping id.
string $dir: 'push'|'pull'|NULL to load limit mappings by push or pull types.
Return value
\Drupal\salesforce_mapping\Entity\SalesforceMappingInterface[] The mappings.
Throws
\Exception
2 calls to SalesforceMappingCommandsBase::getMappingsFromName()
- SalesforceMappingCommandsBase::getPullMappingsFromName in modules/
salesforce_mapping/ src/ Commands/ SalesforceMappingCommandsBase.php - Given a mappin gname, get an array of matching pull mappings.
- SalesforceMappingCommandsBase::getPushMappingsFromName in modules/
salesforce_mapping/ src/ Commands/ SalesforceMappingCommandsBase.php - Given a mapping name, get an array of matching push mappings.
File
- modules/
salesforce_mapping/ src/ Commands/ SalesforceMappingCommandsBase.php, line 150
Class
- SalesforceMappingCommandsBase
- Shared command base for Salesforce Drush commands.
Namespace
Drupal\salesforce_mapping\CommandsCode
protected function getMappingsFromName($name, $dir = NULL) {
if ($name == 'ALL') {
if ($dir == 'pull') {
$mappings = $this->mappingStorage
->loadPullMappings();
}
elseif ($dir == 'push') {
$mappings = $this->mappingStorage
->loadPushMappings();
}
else {
$mappings = $this->mappingStorage
->loadMultiple();
}
}
else {
$mapping = $this->mappingStorage
->load($name);
if ($dir == 'push' && !$mapping
->doesPush()) {
throw new \Exception(dt("Mapping !name does not push.", [
'!name' => $name,
]));
}
elseif ($dir == 'pull' && !$mapping
->doesPull()) {
throw new \Exception(dt("Mapping !name does not pull.", [
'!name' => $name,
]));
}
$mappings = [
$mapping,
];
}
$mappings = array_filter($mappings);
if (empty($mappings)) {
if ($dir == 'push') {
throw new \Exception(dt('No push mappings loaded'));
}
if ($dir == 'pull') {
throw new \Exception(dt('No pull mappings loaded'));
}
}
return $mappings;
}