/** * Initializes the Spire framework. * * @return void */ public static function initialize() { // Start the system. Spire::start(); // Load routes. static::routes(); // Find the current route. $route = Repository::retrieve(Request::method(), Uri::segmentString()); // If no route was found, show a 404. if (empty($route)) { die('404'); } // Instantiate the module. static::$module = $module = new Module($route); // Run the module. $response = $module->run(); // Run the response. if (is_object($response) && method_exists($response, 'respond')) { $response->respond(); } // Do we have a layout to process? $layout = $module->instance()->layout; // Process layout. if ($layout !== '') { echo Layout::get($layout); } // Close Spire. Spire::close(); }
/** * @covers Repository */ public function testRepository() { Repository::store('get', 'about', ['controller' => 'pages', 'action' => 'about']); $stored = Repository::retrieve('get', 'about'); $removed = Repository::remove('get', 'about'); $this->assertInternalType('array', $stored); $this->assertArrayHasKey('controller', $stored); $this->assertArrayHasKey('action', $stored); $this->assertTrue($removed); Repository::store('post', 'login', ['controller' => 'account', 'action' => 'login']); $stored = Repository::retrieve('post', 'login'); $removed = Repository::remove('post', 'login'); $this->assertInternalType('array', $stored); $this->assertArrayHasKey('controller', $stored); $this->assertArrayHasKey('action', $stored); $this->assertTrue($removed); $stored = Repository::retrieve('get', 'notexist'); $removed = Repository::remove('get', 'notexist'); $this->assertInternalType('array', $stored); $this->assertEmpty($stored); $this->assertFalse($removed); }