public function parseConfiguration($importConfiguration) { if (!property_exists($importConfiguration, "importBehaviour")) { return false; throw new \Exception("The key importBehaviour does not exist!"); } if (!in_array($importConfiguration->importBehaviour, self::importBehaviours)) { throw new \Exception("The key importBehaviour contains an invalid value!"); } $this->importBehaviour = $importConfiguration->importBehaviour; switch ($this->importBehaviour) { case self::IMPORTBEHAVIOUR_ALWAYSSETTO: if (!property_exists($importConfiguration, "setToEntity")) { throw new \Exception("The key setToEntity does not exist for mode alwaysSetTo!"); } // @todo Check if setToEntity contains a valid value $this->setToEntity = $importConfiguration->setToEntity; break; case self::IMPORTBEHAVIOUR_MATCHDATA: if (!property_exists($importConfiguration, "matchers")) { throw new \Exception("No matchers defined"); } if (!is_array($importConfiguration->matchers)) { throw new \Exception("matchers must be an array"); } foreach ($importConfiguration->matchers as $matcher) { if (!property_exists($matcher, "matchField") || !property_exists($matcher, "importField") || $matcher->importField == "") { throw new \Exception("matcher configuration error"); } } $this->matchers = $importConfiguration->matchers; if (!property_exists($importConfiguration, "updateBehaviour")) { throw new \Exception("The key updateBehaviour does not exist for mode copyFrom!"); } if (!in_array($importConfiguration->updateBehaviour, self::updateBehaviours)) { throw new \Exception("Invalid value for updateBehaviour"); } $this->updateBehaviour = $importConfiguration->updateBehaviour; if (!property_exists($importConfiguration, "notFoundBehaviour")) { throw new \Exception("The key notFoundBehaviour does not exist for mode copyFrom!"); } if (!in_array($importConfiguration->notFoundBehaviour, self::notFoundBehaviours)) { throw new \Exception("Invalid value for notFoundBehaviour"); } $this->notFoundBehaviour = $importConfiguration->notFoundBehaviour; if ($this->notFoundBehaviour == self::NOTFOUNDBEHAVIOUR_SETTOENTITY) { if (!property_exists($importConfiguration, "notFoundSetToEntity")) { throw new \Exception("The key notFoundSetToEntity does not exist for mode copyFrom!"); } // @todo check if notFoundSetToEntity contains a valid entity $this->notFoundSetToEntity = $importConfiguration->notFoundSetToEntity; } break; default: break; } return parent::parseConfiguration($importConfiguration); }
public function parseConfiguration($importConfiguration) { if (!property_exists($importConfiguration, "importBehaviour")) { return false; } if (!in_array($importConfiguration->importBehaviour, self::importBehaviours)) { throw new \Exception("The key importBehaviour contains an invalid value!"); } $this->importBehaviour = $importConfiguration->importBehaviour; return parent::parseConfiguration($importConfiguration); }