public function RunWorkflow($key) { $logger = \Swiftriver\Core\Setup::GetLogger(); $logger->log("Core::Workflows::EventHandlers::ListAllEventHandlers::RunWorkflow [Method invoked]", \PEAR_LOG_INFO); $logger->log("Core::Workflows::EventHandlers::ListAllEventHandlers::RunWorkflow [START: Constructing the Event Distributor]", \PEAR_LOG_DEBUG); $eventDistributer = new \Swiftriver\Core\EventDistribution\EventDistributor(); $logger->log("Core::Workflows::EventHandlers::ListAllEventHandlers::RunWorkflow [END: Constructing the Event Distributor]", \PEAR_LOG_DEBUG); $logger->log("Core::Workflows::EventHandlers::ListAllEventHandlers::RunWorkflow [START: Getting a full list of Event Handlers from the event distributor]", \PEAR_LOG_DEBUG); $handlers = $eventDistributer->ListAllAvailableEventHandlers(); $logger->log("Core::Workflows::EventHandlers::ListAllEventHandlers::RunWorkflow [END: Getting a full list of Event Handlers from the event distributor]", \PEAR_LOG_DEBUG); $logger->log("Core::Workflows::EventHandlers::ListAllEventHandlers::RunWorkflow [START: Finding out which event handlers are active]", \PEAR_LOG_DEBUG); $config = \Swiftriver\Core\Setup::EventDistributionConfiguration(); $activeHandlers = $config->EventHandlers; if ($activeHandlers != null && is_array($activeHandlers) && $handlers != null && is_array($handlers)) { foreach ($activeHandlers as $activeHandler) { foreach ($handlers as $handler) { if ($handler->Name() == $activeHandler->name) { $handler->active = true; } } } } $logger->log("Core::Workflows::EventHandlers::ListAllEventHandlers::RunWorkflow [END: Finding out which event handlers are active]", \PEAR_LOG_DEBUG); $logger->log("Core::Workflows::EventHandlers::ListAllEventHandlers::RunWorkflow [START: Parsing the handlers to JSON]", \PEAR_LOG_DEBUG); $json = parent::ParseHandlersToJson($handlers); $logger->log("Core::Workflows::EventHandlers::ListAllEventHandlers::RunWorkflow [END: Parsing the handlers to JSON]", \PEAR_LOG_DEBUG); $logger->log("Core::Workflows::EventHandlers::ListAllEventHandlers::RunWorkflow [Method finished]", \PEAR_LOG_INFO); return parent::FormatReturn($json); }
public function RunWorkflow($json, $key) { $logger = \Swiftriver\Core\Setup::GetLogger(); $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [Method invoked]", \PEAR_LOG_INFO); $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [START: Parsing the JSON input]", \PEAR_LOG_DEBUG); try { $name = parent::ParseJsonToEventHandlerName($json); } catch (\Exception $e) { $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG); $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [{$e}]", \PEAR_LOG_ERR); return parent::FormatErrorMessage($e); } $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [END: Parsing the JSON input]", \PEAR_LOG_DEBUG); $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [START: Instanciating the event distributor]", \PEAR_LOG_DEBUG); $eventDistributor = new \Swiftriver\Core\EventDistribution\EventDistributor(); $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [END: Instanciating the event distributor]", \PEAR_LOG_DEBUG); $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [START: Getting all the availabel event handlers]", \PEAR_LOG_DEBUG); $handlers = $eventDistributor->ListAllAvailableEventHandlers(); $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [END: Getting all the availabel event handlers]", \PEAR_LOG_DEBUG); $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [START: Looking for a handler with the matching name]", \PEAR_LOG_DEBUG); foreach ($handlers as $handler) { if ($handler->Name() == $name) { $thisHandler = $handler; } } $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [END: Looking for a handler with the matching name]", \PEAR_LOG_DEBUG); if (!isset($thisHandler) || $thisHandler == null) { return parent::FormatErrorMessage("No event handler found matching the name {$name}"); } $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [START: Constructing the configuration entry]", \PEAR_LOG_DEBUG); $className = $thisHandler->type; $filePath = $thisHandler->filePath; $configEntry = new \Swiftriver\Core\ObjectModel\EventHandlerEntry($name, $className, $filePath); $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [END: Constructing the configuration entry]", \PEAR_LOG_DEBUG); $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [START: Extracting the configured event handlers from the config system]", \PEAR_LOG_DEBUG); $config = \Swiftriver\Core\Setup::EventDistributionConfiguration(); $configuredEventHandlers = $config->EventHandlers; $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [END: Extracting the configured event handlers from the config system]", \PEAR_LOG_DEBUG); $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [START: Looking for an existing config entry for this handler]", \PEAR_LOG_DEBUG); for ($i = 0; $i < count($configuredEventHandlers); $i++) { if ($configuredEventHandlers[$i]->name == $name) { $index = $i; } } $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [END: Looking for an existing config entry for this handler]", \PEAR_LOG_DEBUG); $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [START: Adding a configuration entry for this event handler]", \PEAR_LOG_DEBUG); if (isset($index)) { $configuredEventHandlers[$index] = $configEntry; } else { $configuredEventHandlers[] = $configEntry; } $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [END: Adding a configuration entry for this event handler]", \PEAR_LOG_DEBUG); $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [START: Saving the configuration]", \PEAR_LOG_DEBUG); $config->EventHandlers = $configuredEventHandlers; $config->Save(); $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [END: Saving the configuration]", \PEAR_LOG_DEBUG); $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [Method finished]", \PEAR_LOG_INFO); return parent::FormatMessage("OK"); }
public function RunWorkflow($json, $key) { $logger = \Swiftriver\Core\Setup::GetLogger(); $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [Method invoked]", \PEAR_LOG_INFO); $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [START: Parsing the input JSON]", \PEAR_LOG_DEBUG); try { $name = parent::ParseJsonToEventHandlerName($json); $config = parent::ParseJsonToEventHandlerConfiguration($json); } catch (\Exception $e) { $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [An Exception was thrown]", \PEAR_LOG_ERR); $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [{$e}]", \PEAR_LOG_ERR); return parent::FormatErrorMessage($e); } $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [END: Parsing the input JSON]", \PEAR_LOG_DEBUG); $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [START: Instanciating the event distributor]", \PEAR_LOG_DEBUG); $eventDistributor = new \Swiftriver\Core\EventDistribution\EventDistributor(); $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [END: Instanciating the event distributor]", \PEAR_LOG_DEBUG); $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [START: Listing all event handlers]", \PEAR_LOG_DEBUG); $handlers = $eventDistributor->ListAllAvailableEventHandlers(); $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [END: Listing all event handlers]", \PEAR_LOG_DEBUG); $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [START: Looking for an event handler with matching name]", \PEAR_LOG_DEBUG); foreach ($handlers as $handler) { if ($handler->Name() == $name) { $thisHandler = $handler; } } if (!isset($thisHandler) || $thisHandler == null) { $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [No event handler was found matching the name {$name}]", \PEAR_LOG_DEBUG); return parent::FormatErrorMessage("No event handler was found matching the name {$name}"); } $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [END: Looking for an event handler with matching name]", \PEAR_LOG_DEBUG); $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [START: Adding all the configured properties to the event handler]", \PEAR_LOG_DEBUG); $thisConfig = array(); foreach ($thisHandler->ReturnRequiredParameters() as $param) { foreach ($config as $key => $value) { if ($param->name == $key) { $param->value = $value; } } $thisConfig[] = $param; } $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [END: Adding all the configured properties to the event handler]", \PEAR_LOG_DEBUG); $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [START: Saving the configuration]", \PEAR_LOG_DEBUG); $configuration = \Swiftriver\Core\Setup::DynamicModuleConfiguration(); $configuration->Configuration[$name] = $thisConfig; $configuration->Save(); $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [END: Saving the configuration]", \PEAR_LOG_DEBUG); $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [Method finished]", \PEAR_LOG_INFO); parent::FormatMessage("OK"); }