public function parseError($code, $data = null) { if ($this->_driver) { $this->_driver->processError($this->task); } else { parent::parseError($code, $data); } }
/** @param $task Task */ public function processTask($task) { parent::processTask($task); $data = $task->request->post->get('commands'); if (!is_string($data)) { $this->postResults(array(ServiceResult::createWithError('error', 'No data', '::GLOBAL::'))); return; } if (strlen($data) > $this->maxPackageSize) { $this->postResults(array(ServiceResult::createWithError('error', 'Data too large', '::GLOBAL::'))); return; } $data = json_decode($data, true); if (json_last_error() != JSON_ERROR_NONE || !is_array($data)) { $this->postResults(array(ServiceResult::createWithError('error', 'Invalid data', '::GLOBAL::'))); return; } $results = array(); $f = new ArrayFilter(); foreach ($data as $command) { if (!is_array($command)) { $this->postResults(array(ServiceResult::createWithError('error', 'Invalid data', '::GLOBAL::'))); return; } $f->setData($command); $id = $f->get('id'); $command = $f->get('command'); $data = $f->asFilter('data'); $results[] = $this->_executeCommand($command, $data, $id); } $this->postResults($results); }