/** * Build a message box and get it. */ public function testBuildAndGet() { $object = new MessageBox(['class' => 'test message_box info']); $object->setTitle('Test Box'); $object->addContent(['div', [], 'One']); $object->addContent('Text'); $this->assertSame(['div', ['class' => 'test message_box info'], [['div', ['class' => 'title'], 'Test Box'], ['div', ['class' => 'content'], [['div', [], 'One'], 'Text']]]], $object->get()); }
/** * Handle the shutdown of the system, recording any fatal errors. */ public function handler() { $err = error_get_last(); if (!isset($err['type']) || !in_array($err['type'], [E_USER_ERROR, E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING])) { return; } $this->viewMessageBox->setTitle('Fatal Error'); $this->viewMessageBox->addContent(['p', ['class' => 'Description'], 'This is an error that we were unable to handle. Please tell us any information that could help us ' . 'avoid this error in the future. Useful information such as the date, time and what you were doing ' . 'when the error occurred should help us fix this.']); if (!empty($this->email)) { $this->viewMessageBox->addContent(['div', ['class' => 'Contact'], 'Contact: ' . $this->email]); } if ($this->showError) { $this->viewError->set($err); $this->viewMessageBox->addContent($this->viewError->get()); } $this->writer->write($this->viewMessageBox->get()); $this->response->setStatus(500); $this->response->setBody((string) $this->writer); $this->response->send(); }