/** * get CLI Request * @return void * @throws ApplicationException */ public function initRequest() { $arguments = getopt("u:", ["uri:"]); if (!array_key_exists('u', $arguments) && !array_key_exists('uri', $arguments)) { throw new ApplicationException('Attribute `--uri` is required'); } $uri = $arguments['u'] ?? $arguments['uri']; $request = RequestFactory::fromGlobals(['REQUEST_URI' => $uri, 'REQUEST_METHOD' => 'CLI']); Request::setInstance($request); }
/** * Reset layout and Request */ protected static function resetApp() { if (self::$app) { self::$app->useLayout(true); self::$app->resetRouter(); } Proxy\Auth::clearIdentity(); Proxy\Messages::popAll(); Proxy\Request::setInstance(RequestFactory::fromGlobals()); Proxy\Response::setInstance(new Bluz\Response\Response()); }
/** * Initial Request instance * * @return void */ protected function initRequest() { $request = RequestFactory::fromGlobals(); Request::setInstance($request); }
/** * Get uploaded file * * @param string $name * @return \Zend\Diactoros\UploadedFile */ public static function getFile($name) { return RequestFactory::get($name, self::getInstance()->getUploadedFiles()); }