/** * 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(); }
use Apollo\Components\DB; use Apollo\Components\User; use Apollo\Entities\OrganisationEntity; use Apollo\Entities\PersonEntity; use Apollo\Entities\RecordEntity; use Apollo\Entities\UserEntity; use Faker\Factory; date_default_timezone_set('Europe/London'); Apollo::prepare(); $entity_manager = DB::getEntityManager(); $organisationRepo = $entity_manager->getRepository('Apollo\\Entities\\OrganisationEntity'); /** * @var OrganisationEntity $organisation */ $organisation = $organisationRepo->find(1); $userRepo = User::getRepository(); /** * @var UserEntity $user */ $user = $userRepo->find(1); date_default_timezone_set('Europe/London'); $date = new DateTime(); for ($i = 0; $i < 1; $i++) { $faker = Factory::create(); $person = new PersonEntity(); $person->setOrganisation($organisation); $person->setGivenName($faker->firstName); $person->setMiddleName($faker->firstName); $person->setLastName($faker->lastName); $person->setIsHidden(false); $entity_manager->persist($person);