Skip to content
Snippets Groups Projects
Commit 42646127 authored by jaapjansma's avatar jaapjansma
Browse files

Merge branch 'issue73' into 'master'

port logic from AbstractCivicrmEntitySource to AbstractSource

See merge request !70
parents 5c23dcc6 70f34b0e
No related branches found
No related tags found
1 merge request!70port logic from AbstractCivicrmEntitySource to AbstractSource
......@@ -165,8 +165,18 @@ abstract class AbstractSource implements SourceInterface {
* @throws \Exception
*/
public function ensureFieldInSource(FieldSpecification $fieldSpecification) {
if (!$this->dataFlow->getDataSpecification()->doesFieldExist($fieldSpecification->name)) {
$this->dataFlow->getDataSpecification()->addFieldSpecification($fieldSpecification->name, $fieldSpecification);
try {
$originalFieldSpecification = null;
if ($this->getAvailableFields()->doesAliasExists($fieldSpecification->alias)) {
$originalFieldSpecification = $this->getAvailableFields()->getFieldSpecificationByAlias($fieldSpecification->alias);
} elseif ($this->getAvailableFields()->doesFieldExist($fieldSpecification->name)) {
$originalFieldSpecification = $this->getAvailableFields()->getFieldSpecificationByName($fieldSpecification->name);
}
if ($originalFieldSpecification) {
$this->dataFlow->getDataSpecification()->addFieldSpecification($fieldSpecification->alias, $fieldSpecification);
}
} catch (FieldExistsException $e) {
// Do nothing.
}
return $this;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment