/** * (non-PHPdoc) * * @see \Zend\Mvc\Controller\AbstractRestfulController::getList() */ public function getList() { $response = $this->getResponse(); $configurationHandler = $this->getConfigurationHandler(); $configuration = $configurationHandler->getConfiguration(); $response->getHeaders()->addHeaderLine('Content-Type', 'application/json'); $adapter = new Json(); $response->setContent($adapter->serialize($configuration)); return $response; }
/** * * @return boolean|\Zend\Stdlib\ResponseInterface */ public function executeAction() { set_time_limit(0); // TODO magical value ini_set('memory_limit', '1800M'); $verbose = true; $responseContent = array(); $processExecutionHandler = $this->getProcessExecutionHandler(); $processInformation = $processExecutionHandler->executeNextProcess($verbose); $processUpdater = $this->getProcessUpdater(); $processUpdater->cleanOldExecutions(); $response = $this->getResponse(); $adapter = new Json(); $response->setContent($adapter->serialize($processInformation)); return $response; }
public function handleRestApiError(MvcEvent $e) { if (array_key_exists('exception', $e->getParams())) { $exception = $e->getParams()['exception']; if ($exception instanceof RestApiException) { $e->stopPropagation(); $response = $e->getResponse(); $response->setStatusCode('400'); $response->getHeaders()->addHeaderLine('Content-Type', 'application/json'); $adapter = new Json(); $errorData = $exception->getErrorData(); $original = $exception->getOriginal(); $count = 0; while ($original instanceof \Exception) { $errorData['previous-' . $count] = $original->getMessage() . '/' . $original->getFile() . '/' . $original->getLine(); $original = $original->getPrevious(); $count++; } $response->setContent($adapter->serialize($errorData)); $response->sendHeaders(); $response->sendContent(); exit; } } }
/** * (non-PHPdoc) * * @see \Zend\Mvc\Controller\AbstractRestfulController::create() */ public function create($data) { set_time_limit(0); ignore_user_abort(true); //TODO magical value ini_set('memory_limit', '1800M'); $verbose = $this->params()->fromQuery('verbose', false); $verbose = $verbose !== false; $responseContent = array(); $processExecutionHandler = $this->getProcessExecutionHandler(); $processInformation = $processExecutionHandler->executeNextProcess($verbose); $processUpdater = $this->getProcessUpdater(); $processUpdater->cleanOldExecutions(); $response = $this->getResponse(); $response->getHeaders()->addHeaderLine('Content-Type', 'application/json'); $adapter = new Json(); $response->setContent($adapter->serialize($processInformation)); return $response; }
public function testUnserializeSpecificAdapter() { $adapter = new Adapter\Json(); $value = '"test"'; $expected = $adapter->unserialize($value); $this->assertEquals($expected, Serializer::unserialize($value, array('adapter' => $adapter))); }
public function testUnserialzeInvalid() { $value = 'not a serialized string'; $this->setExpectedException('Zend\\Serializer\\Exception\\RuntimeException', 'Unserialization failed: Decoding failed: Syntax error'); $this->adapter->unserialize($value); }