/** * Initialises the application by checking if the user if authorised, if the request is valid * and redirecting the user to the default page if the index is accessed. * * All request parsing is done in a separate function, parseRequest(); * * @since 0.1.0 Now uses the DEFAULT_CONTROLLER constant * @since 0.0.9 Moved request parsing to parseRequest() function, redirect to default now raises 301 code * @since 0.0.8 No longer provides arbitrary amount of parameters, use the Request instance instead * @since 0.0.7 Made index() in RecordController the default action * @since 0.0.6 Now uses notFound() function from the controller instead of custom error * @since 0.0.5 Error pages are now rendered using the Request class * @since 0.0.4 Improved parameter to argument conversion to allow arbitrary amount of arguments * @since 0.0.3 Added conversion from request parameters to function arguments * @since 0.0.2 Proper controller/action parsing * @since 0.0.1 */ public function start() { if ($this->user->isGuest()) { if ($this->request->getController() != 'User' || $this->request->getAction() != 'SignIn') { $this->request->sendTo('user/sign-in/' . (empty($this->request->getStrippedUrl()) ? '' : '?return=' . $this->request->getStrippedUrl()), false); } } if ($this->request->isIndex()) { http_response_code(301); $this->request->sendTo(DEFAULT_CONTROLLER); } if (!$this->getRequest()->isValid()) { $this->request->error(400, 'The requested URL is malformed.'); } $this->parseRequest(); }