public function executeNew(sfWebRequest $request) { //$this->form = new EtvaAsynchronousJobForm(); $msg_i18n = $this->getContext()->getI18N()->__('unknown error', array()); $result = array('success' => false, 'error' => $msg_i18n, 'agent' => sfConfig::get('config_acronym')); if ($request->isMethod('post')) { $formdata = (array) json_decode($request->getParameter('asynchronousjob')); $formdata['user'] = $this->getUser()->getGuardUser()->getUsername(); $asyncjob = new EtvaAsynchronousJob(); $asyncjob->fromArray($formdata, BasePeer::TYPE_FIELDNAME); try { $asynctask = $asyncjob->getTask($this->dispatcher); } catch (Exception $e) { $result = array('success' => false, 'error' => $e->getMessage(), 'agent' => sfConfig::get('config_acronym')); } if ($asynctask) { // calc dependencies if ($depends = $asyncjob->calcDepends($formdata['depends'], $this->dispatcher)) { $asyncjob->setDepends($depends); } // save $asyncjob->save(); $taskdesc = $asynctask->getBriefDescription() ? $asynctask->getBriefDescription() : $asyncjob->getTasknamespace() . ":" . $asyncjob->getTaskname(); $taskdesc_i18n = $this->getContext()->getI18N()->__($taskdesc, array()); $msg_i18n = $this->getContext()->getI18N()->__('Task \'%task%\' created successfully.', array('%task%' => $taskdesc_i18n)); //error_log("executeNew Task '$taskdesc' deps=".$asyncjob->getDepends(). " formdata=".$formdata['depends']); $result = array('success' => true, 'response' => $msg_i18n, 'agent' => sfConfig::get('config_acronym'), 'asynchronousjob' => $asyncjob->toArray()); } else { $msg_i18n = $this->getContext()->getI18N()->__('Asynchronous job with invalid task!', array()); $result = array('success' => false, 'error' => $msg_i18n, 'agent' => sfConfig::get('config_acronym')); } } return $this->returnResponse($result); }