EventDistributionConfiguration() 공개 정적인 메소드

Static access to the Event distribution config handler
public static EventDistributionConfiguration ( ) : EventDistributionConfigurationHandler
리턴 Swiftriver\Core\Configuration\ConfigurationHandlers\EventDistributionConfigurationHandler
 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");
 }
예제 #3
0
 /**
  * The constructor for the EventDistributor class
  */
 public function __construct()
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::EventDistribution::EventDistributor::__construct [Method invoked]", \PEAR_LOG_DEBUG);
     $logger->log("Core::EventDistribution::EventDistributor::__construct [START: Adding configured event handlers]", \PEAR_LOG_DEBUG);
     $this->eventHandlers = \Swiftriver\Core\Setup::EventDistributionConfiguration()->EventHandlers;
     $logger->log("Core::EventDistribution::EventDistributor::__construct [END: Adding configured event handlers]", \PEAR_LOG_DEBUG);
     $logger->log("Core::EventDistribution::EventDistributor::__construct [Method finished]", \PEAR_LOG_DEBUG);
 }