public function execute() { $presenter = new RegisteredPresenter(); $result = $this->resultFactory->create(ResultFactory::TYPE_JSON); $result->setData($presenter->toArray()); return $result; }
public function registeredAction() { $this->getResponse()->setHeader('Content-Type', 'application/json'); $route = $this->resolver->process(preg_replace('/.*(expressly\\/.*)/i', '/${1}', $_SERVER['REQUEST_URI'])); if ($route instanceof Route) { $presenter = new RegisteredPresenter(); $this->getResponse()->setBody(json_encode($presenter->toArray())); } else { $this->getResponse()->setHttpResponseCode(401); } }
public function testToArray() { $presenter = new RegisteredPresenter(); $this->assertEquals(array('registered' => true), $presenter->toArray()); $this->assertJson(json_encode($presenter->toArray())); }