/** * @return int */ public function execute() { $collection = new MapperDataCollection(new ProcessMessage()); $config = new Config(); $config->setData("mapper_class", get_class(new Campaign())); $configGroup = new ConfigGroup(); $configGroup->addConfig("process", $config); $collection->configure($configGroup); echo json_pretty($collection->getAttributes()); }
/** * @return int */ public function execute() { // Instantiate and set data for the actual message $message = new ProcessMessage(); $message->setData("firstName", $this->firstName); $message->setData("lastName", $this->lastName); $message->setData("name", "{$this->firstName} {$this->lastName}"); $message->setData("email", $this->email); // Build a config object for use in a Rule. This needs to be wrapped in a // config group and added to a process definition as well as the full class // name for the rule and some default requirements. // Once fully setup we add the process definition to the message processor. $config = new Config(); $config->setData("attribute_name", "firstName"); $config->setData("attribute_check", $this->firstName); $config->setData("attribute_check_type", AttributeFilter::MATCH_EQUAL); $configGroup = new ConfigGroup(); $configGroup->addConfig("process", $config); $process = new ProcessDefinition(); $process->setProcessClass('Qubes\\Defero\\Components\\Campaign\\Rules\\Filter\\AttributeFilter'); $process->setQueueName("defero"); $process->setQueueService("queue"); $process->configure($configGroup); $message->addProcess($process); // Same as above. Running the same check on a different variable. $config = new Config(); $config->setData("attribute_name", "lastName"); $config->setData("attribute_check", $this->lastName); $config->setData("attribute_check_type", AttributeFilter::MATCH_EQUAL); $configGroup = new ConfigGroup(); $configGroup->addConfig("process", $config); $process = new ProcessDefinition(); $process->setProcessClass('Qubes\\Defero\\Components\\Campaign\\Rules\\Filter\\AttributeFilter'); $process->setQueueName("defero"); $process->setQueueService("queue"); $process->configure($configGroup); $message->addProcess($process); // Here we add a delivery rule, $process = new ProcessDefinition(); /*$process->setProcessClass( 'Qubes\Defero\Components\Campaign\Rules\Delivery\FailDeliveryRule' );*/ $process->setProcessClass('Qubes\\Defero\\Components\\Campaign\\Rules\\Delivery\\DelayDeliveryRule'); $config = new Config(); $config->setData("delay", 60); $configGroup = new ConfigGroup(); $configGroup->addConfig("process", $config); $process->configure($configGroup); $process->setQueueName("defero"); $process->setQueueService("queue"); $message->addProcess($process); // Final process is used to send the message $process = new ProcessDefinition(); $process->setQueueName("defero"); $process->setQueueService("queue"); $process->setProcessClass('Qubes\\Defero\\Components\\Campaign\\Process\\EmailService\\Smtp'); $message->addProcess($process); \Queue::setDefaultQueueProvider("messagequeue"); \Queue::push(new StdQueue("defero_messages"), serialize($message)); }