+
+ /**
+ * Prepares a message as answer for given message data for delivery.
+ *
+ * @param $messageData An array with all message data
+ * @param $packageInstance An instance of a Deliverable instance
+ * @return void
+ */
+ protected function prepareAnswerMessage (array $messageData, Deliverable $packageInstance) {
+ // Get a helper instance based on this handler's name
+ $helperInstance = ObjectFactory::createObjectByConfiguredName('node_answer_' . $this->getHandlerName() . '_helper_class', array($messageData));
+
+ // Load descriptor XML
+ $helperInstance->loadDescriptorXml();
+
+ /*
+ * Set missing (temporary) configuration data, mostly it needs to be
+ * copied from message data array.
+ */
+ $this->initMessageConfigurationData($messageData);
+
+ // Compile any configuration variables
+ $helperInstance->getTemplateInstance()->compileConfigInVariables();
+
+ // Get node instance
+ $nodeInstance = Registry::getRegistry()->getInstance('node');
+
+ // Deliver the package
+ $helperInstance->sendPackage($nodeInstance);
+
+ /*
+ * Remove temporary configuration
+ */
+ $this->removeMessageConfigurationData($messageData);
+ }
+
+ /**
+ * Initializes configuration data from given message data array
+ *
+ * @param $messageData An array with all message data
+ * @return void
+ */
+ abstract protected function initMessageConfigurationData (array $messageData);
+
+ /**
+ * Removes configuration data with given message data array from global
+ * configuration
+ *
+ * @param $messageData An array with all message data
+ * @return void
+ */
+ abstract protected function removeMessageConfigurationData (array $messageData);