public function renderNew()
 {
     $definedProcessors = $this->config('processors')->jsonSerialize();
     $form = new DeferoForm('edit_processor');
     $form->addSelectElement('processorType', array_map('class_shortname', $definedProcessors));
     $form->addSubmitElement();
     $form->get('processorType')->setRequired(true);
     $form->hydrate($this->request()->postVariables());
     if ($form->isValid() && $form->csrfCheck()) {
         $campaign = $this->_campaign;
         $processors = $campaign->processors;
         $processors[] = $form->jsonSerialize();
         $campaign->processors = $processors;
         $campaign->saveChanges();
         end($processors);
         return Redirect::to('/campaigns/' . $this->getInt('cid') . '/processors/' . key($processors) . '/edit');
     }
     return $form;
 }
Example #2
0
 public function renderTest($id)
 {
     $campaign = new Campaign($id);
     $form = new DeferoForm('send_test_email');
     $form->addTextElement('email');
     foreach ($campaign->message()->findVariables() as $var) {
         $form->addTextElement($var);
     }
     $form->get('email')->setRequired(true);
     $form->addSubmitElement();
     if ($post = $this->request()->postVariables()) {
         $form->hydrate($post);
         if ($form->isValid() && $form->csrfCheck(true)) {
             try {
                 Defero::pushMessage($id, $form->jsonSerialize());
                 $msg = new TransportMessage("info", 'Test queued for user');
             } catch (\Exception $e) {
                 $msg = new TransportMessage("error", $e->getMessage());
             }
             return Redirect::to("/campaigns/{$id}")->with("msg", $msg);
         }
     }
     return new RenderGroup('<h1>Send a Test Campaign</h1>', $form);
 }