Exemple #1
0
 protected function dispatch(Request $request)
 {
     $method = $request->getMethod();
     if (!is_string($method)) {
         throw new ApiException(405, 'Unsupported HTTP method; must be a string, received ' . (is_object($method) ? get_class($method) : gettype($method)));
     }
     $method = strtoupper($method);
     /** @var Resource $resource */
     $resource = $this->getResource();
     if ('GET' === $method) {
         if ($id = $request->getAttribute(static::PK)) {
             $result = $resource->fetch($id, $request->getQueryParams());
         } else {
             $result = $resource->fetchAll($request->getQueryParams());
         }
     } elseif ('POST' === $method) {
         $result = $resource->create($request->getParsedBody());
     } elseif ('PUT' === $method) {
         $result = $resource->update($request->getAttribute(static::PK), $request->getParsedBody());
     } elseif ('PATCH' === $method) {
         $result = $resource->patch($request->getAttribute(static::PK), $request->getParsedBody());
     } elseif ('DELETE' === $method) {
         $result = $resource->delete($request->getAttribute(static::PK));
     } else {
         throw new ApiException(405, 'The ' . $method . ' method has not been defined');
     }
     return $result;
 }
 public function __invoke(Request $request)
 {
     /** Check for token on header */
     if (isset($this->options['header'])) {
         if ($request->hasHeader($this->options['header'])) {
             $header = $request->getHeader($this->options['header'])[0];
             if (preg_match($this->options['regex'], $header, $matches)) {
                 return $matches[1];
             }
         }
     }
     /** If nothing on header, try query parameters */
     if (isset($this->options['parameter'])) {
         if (!empty($request->getQueryParams()[$this->options['parameter']])) {
             return $request->getQueryParams()[$this->options['parameter']];
         }
     }
     /** If nothing on parameters, try cookies */
     if (isset($this->options['cookie'])) {
         $cookie_params = $request->getCookieParams();
         if (!empty($cookie_params[$this->options["cookie"]])) {
             return $cookie_params[$this->options["cookie"]];
         }
     }
     /** If nothing until now, check argument as last try */
     if (isset($this->options['argument'])) {
         if ($route = $request->getAttribute('route')) {
             $argument = $route->getArgument($this->options['argument']);
             if (!empty($argument)) {
                 return $argument;
             }
         }
     }
     throw new TokenNotFoundException('Token not found');
 }
 /**
  * Renders/Echoes the ajax output
  *
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @return ResponseInterface|NULL
  * @throws \InvalidArgumentException
  */
 public function processRequest(ServerRequestInterface $request, ResponseInterface $response)
 {
     $action = isset($request->getParsedBody()['action']) ? $request->getParsedBody()['action'] : (isset($request->getQueryParams()['action']) ? $request->getQueryParams()['action'] : '');
     if (!in_array($action, array('route', 'getAPI'), true)) {
         return null;
     }
     $this->routeAction($action);
     return $this->ajaxObject->render();
 }
 /**
  * Convert a PSR-7 ServerRequest to a Zend\Http server-side request.
  *
  * @param ServerRequestInterface $psr7Request
  * @param bool $shallow Whether or not to convert without body/file
  *     parameters; defaults to false, meaning a fully populated request
  *     is returned.
  * @return Zend\Request
  */
 public static function toZend(ServerRequestInterface $psr7Request, $shallow = false)
 {
     if ($shallow) {
         return new Zend\Request($psr7Request->getMethod(), $psr7Request->getUri(), $psr7Request->getHeaders(), $psr7Request->getCookieParams(), $psr7Request->getQueryParams(), [], [], $psr7Request->getServerParams());
     }
     $zendRequest = new Zend\Request($psr7Request->getMethod(), $psr7Request->getUri(), $psr7Request->getHeaders(), $psr7Request->getCookieParams(), $psr7Request->getQueryParams(), $psr7Request->getParsedBody() ?: [], self::convertUploadedFiles($psr7Request->getUploadedFiles()), $psr7Request->getServerParams());
     $zendRequest->setContent($psr7Request->getBody());
     return $zendRequest;
 }
Exemple #5
0
 public function __invoke(Request $req, Response $res, callable $next) : Response
 {
     if (isset($req->getQueryParams()['redirect'])) {
         $redirect = $this->session->getSegment('redirect');
         $redirect->set('auth', $req->getQueryParams()['redirect']);
     }
     $auth = new Opauth($this->config);
     return $res;
 }
 /**
  * {@inheritdoc}
  */
 public function getData()
 {
     $headers = [];
     foreach ($this->request->getHeaders() as $name => $values) {
         $headers[$name] = implode(', ', $values);
     }
     $data = ['SERVER' => $this->request->getServerParams(), 'QUERY' => $this->request->getQueryParams(), 'COOKIES' => $this->request->getCookieParams(), 'HEADERS' => $headers, 'ATTRIBUTES' => $this->request->getAttributes()];
     return $data;
 }
 /**
  * Processes all AJAX calls and returns a JSON for the data
  *
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @return ResponseInterface
  */
 public function processAjaxRequest(ServerRequestInterface $request, ResponseInterface $response)
 {
     // do the regular / main logic, depending on the action parameter
     $action = isset($request->getParsedBody()['action']) ? $request->getParsedBody()['action'] : $request->getQueryParams()['action'];
     $key = isset($request->getParsedBody()['key']) ? $request->getParsedBody()['fileName'] : $request->getQueryParams()['key'];
     $value = isset($request->getParsedBody()['value']) ? $request->getParsedBody()['value'] : $request->getQueryParams()['value'];
     $content = $this->process($action, $key, $value);
     $response->getBody()->write(json_encode($content));
     return $response;
 }
Exemple #8
0
 /**
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @param callable|null $next
  * @return HtmlResponse
  */
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next = null)
 {
     $templateName = $this->defaultTemplateName;
     $layoutName = $this->defaultLayoutName;
     if (isset($request->getQueryParams()['t'])) {
         $templateName = $request->getQueryParams()['t'];
     }
     if (isset($request->getQueryParams()['l'])) {
         $layoutName = $request->getQueryParams()['l'];
     }
     return new HtmlResponse($this->template->render('proto::' . $templateName, ['layout' => 'proto-layout::' . $layoutName]));
 }
 /**
  * Checks if the request token is valid. This is checked to see if the route is really
  * created by the same instance. Should be called for all routes in the backend except
  * for the ones that don't require a login.
  *
  * @param \Psr\Http\Message\ServerRequestInterface $request
  * @return bool
  * @see \TYPO3\CMS\Backend\Routing\UriBuilder where the token is generated.
  */
 protected function isValidRequest($request)
 {
     $route = $request->getAttribute('route');
     if ($route->getOption('access') === 'public') {
         return true;
     } elseif ($route->getOption('ajax')) {
         $token = (string) (isset($request->getParsedBody()['ajaxToken']) ? $request->getParsedBody()['ajaxToken'] : $request->getQueryParams()['ajaxToken']);
         return $this->getFormProtection()->validateToken($token, 'ajaxCall', $route->getOption('_identifier'));
     } else {
         $token = (string) (isset($request->getParsedBody()['token']) ? $request->getParsedBody()['token'] : $request->getQueryParams()['token']);
         return $this->getFormProtection()->validateToken($token, 'route', $route->getOption('_identifier'));
     }
 }
 /**
  * Set up the application and shut it down afterwards
  *
  * @param callable $execute
  * @return void
  */
 public function run(callable $execute = null)
 {
     $this->request = \TYPO3\CMS\Core\Http\ServerRequestFactory::fromGlobals();
     // see below when this option is set and Bootstrap::defineTypo3RequestTypes() for more details
     if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX) {
         $this->request = $this->request->withAttribute('isAjaxRequest', true);
     } elseif (isset($this->request->getQueryParams()['M'])) {
         $this->request = $this->request->withAttribute('isModuleRequest', true);
     }
     $this->bootstrap->handleRequest($this->request);
     if ($execute !== null) {
         call_user_func($execute);
     }
     $this->bootstrap->shutdown();
 }
 /**
  * Handles an install tool request
  * Execute 'tool' or 'step' controller depending on install[controller] GET/POST parameter
  *
  * @param ServerRequestInterface $request
  * @return void
  */
 public function handleRequest(ServerRequestInterface $request)
 {
     $getPost = !empty($request->getQueryParams()['install']) ? $request->getQueryParams()['install'] : $request->getParsedBody()['install'];
     switch ($getPost['controller']) {
         case 'tool':
             $controllerClassName = \TYPO3\CMS\Install\Controller\ToolController::class;
             break;
         case 'ajax':
             $controllerClassName = \TYPO3\CMS\Install\Controller\AjaxController::class;
             break;
         default:
             $controllerClassName = \TYPO3\CMS\Install\Controller\StepController::class;
     }
     GeneralUtility::makeInstance($controllerClassName)->execute();
 }
Exemple #12
0
 /**
  * Sets the TYPO3 Backend context to a certain workspace,
  * called by the Backend toolbar menu
  *
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @return ResponseInterface
  */
 public function switchWorkspaceAction(ServerRequestInterface $request, ResponseInterface $response)
 {
     $parsedBody = $request->getParsedBody();
     $queryParams = $request->getQueryParams();
     $workspaceId = (int) (isset($parsedBody['workspaceId']) ? $parsedBody['workspaceId'] : $queryParams['workspaceId']);
     $pageId = (int) (isset($parsedBody['pageId']) ? $parsedBody['pageId'] : $queryParams['pageId']);
     $finalPageUid = 0;
     $originalPageId = $pageId;
     $this->getBackendUser()->setWorkspace($workspaceId);
     while ($pageId) {
         $page = BackendUtility::getRecordWSOL('pages', $pageId, '*', ' AND pages.t3ver_wsid IN (0, ' . $workspaceId . ')');
         if ($page) {
             if ($this->getBackendUser()->doesUserHaveAccess($page, 1)) {
                 break;
             }
         } else {
             $page = BackendUtility::getRecord('pages', $pageId);
         }
         $pageId = $page['pid'];
     }
     if (isset($page['uid'])) {
         $finalPageUid = (int) $page['uid'];
     }
     $ajaxResponse = ['title' => \TYPO3\CMS\Workspaces\Service\WorkspaceService::getWorkspaceTitle($workspaceId), 'workspaceId' => $workspaceId, 'pageId' => $finalPageUid && $originalPageId == $finalPageUid ? null : $finalPageUid];
     $response->getBody()->write(json_encode($ajaxResponse));
     return $response;
 }
 protected function delete(ServerRequestInterface $request)
 {
     $this->assertAdmin($request->getAttribute('actor'));
     $name = array_get($request->getQueryParams(), 'name');
     $this->extensions->disable($name);
     $this->extensions->uninstall($name);
 }
Exemple #14
0
 /**
  * {@inheritdoc}
  */
 protected function data(ServerRequestInterface $request, Document $document)
 {
     $id = array_get($request->getQueryParams(), 'id');
     $actor = $request->getAttribute('actor');
     $file = array_get($request->getUploadedFiles(), 'avatar');
     return $this->bus->dispatch(new UploadAvatar($id, $file, $actor));
 }
 /**
  * @param Request $request
  * @return \Psr\Http\Message\ResponseInterface|RedirectResponse
  */
 public function handle(Request $request)
 {
     $redirectUri = (string) $request->getAttribute('originalUri', $request->getUri())->withQuery('');
     $server = new Twitter(['identifier' => $this->settings->get('flarum-auth-twitter.api_key'), 'secret' => $this->settings->get('flarum-auth-twitter.api_secret'), 'callback_uri' => $redirectUri]);
     $session = $request->getAttribute('session');
     $queryParams = $request->getQueryParams();
     $oAuthToken = array_get($queryParams, 'oauth_token');
     $oAuthVerifier = array_get($queryParams, 'oauth_verifier');
     if (!$oAuthToken || !$oAuthVerifier) {
         $temporaryCredentials = $server->getTemporaryCredentials();
         $session->set('temporary_credentials', serialize($temporaryCredentials));
         $session->save();
         // Second part of OAuth 1.0 authentication is to redirect the
         // resource owner to the login screen on the server.
         $server->authorize($temporaryCredentials);
         exit;
     }
     // Retrieve the temporary credentials we saved before
     $temporaryCredentials = unserialize($session->get('temporary_credentials'));
     // We will now retrieve token credentials from the server
     $tokenCredentials = $server->getTokenCredentials($temporaryCredentials, $oAuthToken, $oAuthVerifier);
     $user = $server->getUserDetails($tokenCredentials);
     $identification = ['twitter_id' => $user->uid];
     $suggestions = ['username' => $user->nickname, 'avatarUrl' => str_replace('_normal', '', $user->imageUrl)];
     return $this->authResponse->make($request, $identification, $suggestions);
 }
 /**
  * {@inheritdoc}
  */
 protected function delete(ServerRequestInterface $request)
 {
     $id = array_get($request->getQueryParams(), 'id');
     $actor = $request->getAttribute('actor');
     $input = $request->getParsedBody();
     $this->bus->dispatch(new DeleteDiscussion($id, $actor, $input));
 }
 /**
  * {@inheritdoc}
  */
 protected function data(ServerRequestInterface $request, Document $document)
 {
     $actor = $request->getAttribute('actor');
     $discussionId = array_get($request->getQueryParams(), 'id');
     $data = array_get($request->getParsedBody(), 'data', []);
     $discussion = $this->bus->dispatch(new EditDiscussion($discussionId, $actor, $data));
     // TODO: Refactor the ReadDiscussion (state) command into EditDiscussion?
     // That's what extensions will do anyway.
     if ($readNumber = array_get($data, 'attributes.readNumber')) {
         $state = $this->bus->dispatch(new ReadDiscussion($discussionId, $actor, $readNumber));
         $discussion = $state->discussion;
     }
     if ($posts = $discussion->getModifiedPosts()) {
         $discussionPosts = $discussion->postsVisibleTo($actor)->orderBy('time')->lists('id')->all();
         foreach ($discussionPosts as &$id) {
             foreach ($posts as $post) {
                 if ($id == $post->id) {
                     $id = $post;
                     $post->discussion = $post->discussion_id;
                     $post->user = $post->user_id;
                 }
             }
         }
         $discussion->setRelation('posts', $discussionPosts);
         $this->include = array_merge($this->include, ['posts', 'posts.discussion', 'posts.user']);
     }
     return $discussion;
 }
 /**
  * Generates a cache key based on a unique request.
  *
  * @todo determine parts required for unique request
  * @param ServerRequestInterface $request
  * @return string
  */
 private function generateKey(ServerRequestInterface $request)
 {
     $params = $request->getQueryParams();
     ksort($params);
     $parts = [$request->getMethod(), $request->getUri()->getPath(), serialize($params)];
     return sha1(implode(':', $parts));
 }
 public function __construct(Request $request, Response $response)
 {
     $this->request = $request;
     $this->response = $response;
     $this->getInput = $request->getQueryParams();
     $this->postInput = $request->getParsedBody();
 }
 /**
  * Init function, setting the input vars in the global space.
  *
  * @return void
  * @throws \InvalidArgumentException
  * @throws \TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException
  */
 public function initialize()
 {
     $fileUid = isset($this->request->getQueryParams()['file']) ? $this->request->getQueryParams()['file'] : null;
     $parametersArray = isset($this->request->getQueryParams()['parameters']) ? $this->request->getQueryParams()['parameters'] : null;
     // If no file-param or parameters are given, we must exit
     if (!$fileUid || !isset($parametersArray) || !is_array($parametersArray)) {
         throw new \InvalidArgumentException('No valid fileUid given');
     }
     // rebuild the parameter array and check if the HMAC is correct
     $parametersEncoded = implode('', $parametersArray);
     /* For backwards compatibility the HMAC is transported within the md5 param */
     $hmacParameter = isset($this->request->getQueryParams()['md5']) ? $this->request->getQueryParams()['md5'] : null;
     $hmac = GeneralUtility::hmac(implode('|', array($fileUid, $parametersEncoded)));
     if ($hmac !== $hmacParameter) {
         throw new \InvalidArgumentException('hash does not match');
     }
     // decode the parameters Array
     $parameters = unserialize(base64_decode($parametersEncoded));
     foreach ($parameters as $parameterName => $parameterValue) {
         $this->{$parameterName} = $parameterValue;
     }
     if (MathUtility::canBeInterpretedAsInteger($fileUid)) {
         $this->file = ResourceFactory::getInstance()->getFileObject((int) $fileUid);
     } else {
         $this->file = ResourceFactory::getInstance()->retrieveFileOrFolderObject($fileUid);
     }
     $this->frame = isset($this->request->getQueryParams()['frame']) ? $this->request->getQueryParams()['frame'] : null;
 }
 public function __invoke(Request $req, Response $res, callable $next) : Response
 {
     $middleware = $this->middleware;
     $id = $req->getAttribute('id', false);
     if (!empty($req->getQueryParams()['amp'])) {
         $id .= '-amp';
     }
     // Caching is disabled, or no identifier present; invoke the middleware.
     if (!$this->enabled || !$id) {
         return $middleware($req, $res, $next);
     }
     $result = $this->fetchFromCache($id, $res);
     // Hit cache; resturn response.
     if ($result instanceof Response) {
         return $result;
     }
     // Invoke middleware
     $result = $middleware($req, $res, $next);
     // Result is not a response; cannot cache; error condition.
     if (!$result instanceof Response) {
         return $next($req, $res, $result);
     }
     // Result represents an error response; cannot cache.
     if (300 <= $result->getStatusCode()) {
         return $result;
     }
     // Cache result
     $this->cache($id, $result);
     return $result;
 }
 /**
  * {@inheritDoc}
  * @throws OAuth2Exception
  */
 public function createAuthorizationResponse(ServerRequestInterface $request, Client $client, TokenOwnerInterface $owner = null)
 {
     $queryParams = $request->getQueryParams();
     // We must validate some parameters first
     $responseType = $queryParams['response_type'] ?? null;
     if ($responseType !== self::GRANT_RESPONSE_TYPE) {
         throw OAuth2Exception::invalidRequest(sprintf('The desired grant type must be "code", but "%s" was given', $responseType));
     }
     // We try to fetch the redirect URI from query param as per spec, and if none found, we just use
     // the first redirect URI defined in the client
     $redirectUri = $queryParams['redirect_uri'] ?? $client->getRedirectUris()[0];
     // If the redirect URI cannot be found in the list, we throw an error as we don't want the user
     // to be redirected to an unauthorized URL
     if (!$client->hasRedirectUri($redirectUri)) {
         throw OAuth2Exception::invalidRequest('Redirect URI does not match the registered one');
     }
     // Scope and state allow to perform additional validation
     $scope = $queryParams['scope'] ?? null;
     $state = $queryParams['state'] ?? null;
     $authorizationCode = new AuthorizationCode();
     $authorizationCode->setRedirectUri($redirectUri);
     $this->populateToken($authorizationCode, $client, $owner, $scope);
     $authorizationCode = $this->authorizationCodeService->createToken($authorizationCode);
     $uri = http_build_query(array_filter(['code' => $authorizationCode->getToken(), 'state' => $state]));
     return new Response\RedirectResponse($redirectUri . '?' . $uri);
 }
 /**
  * Process add media request
  *
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @return ResponseInterface
  */
 public function mainAction(ServerRequestInterface $request, ResponseInterface $response)
 {
     $files = $request->getParsedBody()['file'];
     $newMedia = [];
     if (isset($files['newMedia'])) {
         $newMedia = (array) $files['newMedia'];
     }
     foreach ($newMedia as $media) {
         if (!empty($media['url']) && !empty($media['target'])) {
             $allowed = !empty($media['allowed']) ? GeneralUtility::trimExplode(',', $media['allowed']) : [];
             $file = $this->addMediaFromUrl($media['url'], $media['target'], $allowed);
             if ($file !== null) {
                 $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $file->getName(), $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:online_media.new_media.added'), FlashMessage::OK, true);
             } else {
                 $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:online_media.error.invalid_url'), $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:online_media.error.new_media.failed'), FlashMessage::ERROR, true);
             }
             $this->addFlashMessage($flashMessage);
         }
     }
     $redirect = isset($request->getParsedBody()['redirect']) ? $request->getParsedBody()['redirect'] : $request->getQueryParams()['redirect'];
     $redirect = GeneralUtility::sanitizeLocalUrl($redirect);
     if ($redirect) {
         $response = $response->withHeader('Location', GeneralUtility::locationHeaderUrl($redirect))->withStatus(303);
     }
     return $response;
 }
Exemple #24
0
 public function __construct(ServerRequestInterface $request)
 {
     $this->body = $request->getParsedBody();
     foreach ($request->getQueryParams() as $param => $value) {
         switch ($param) {
             case 'sort':
                 $parts = explode(',', $value);
                 foreach ($parts as $part) {
                     preg_match_all('/^(\\-)?([\\w]+)$/', $part, $matches);
                     if (empty($matches[0])) {
                         throw new \Exception('Invalid sort format.', 1);
                     }
                     $name = $matches[2][0];
                     $order = $matches[1][0];
                     $this->sort[$name] = $order;
                 }
                 break;
             case 'pageSize':
             case 'pageNumber':
                 $this->{$param} = $value;
                 break;
             default:
                 $this->userFilters[$param] = $value;
         }
     }
 }
 /**
  * Handles any backend request
  *
  * @param ServerRequestInterface $request
  * @return NULL|ResponseInterface
  */
 public function handleRequest(ServerRequestInterface $request)
 {
     // enable dispatching via Request/Response logic only for typo3/index.php
     // This fallback will be removed in TYPO3 CMS 8, as only index.php will be allowed
     $path = substr($request->getUri()->getPath(), strlen(GeneralUtility::getIndpEnv('TYPO3_SITE_PATH')));
     $routingEnabled = $path === TYPO3_mainDir . 'index.php' || $path === TYPO3_mainDir;
     $proceedIfNoUserIsLoggedIn = false;
     if ($routingEnabled) {
         $pathToRoute = (string) $request->getQueryParams()['route'];
         // Allow the login page to be displayed if routing is not used and on index.php
         if (empty($pathToRoute)) {
             $pathToRoute = '/login';
         }
         $request = $request->withAttribute('routePath', $pathToRoute);
         // Evaluate the constant for skipping the BE user check for the bootstrap
         // should be handled differently in the future by checking the Bootstrap directly
         if ($pathToRoute === '/login') {
             $proceedIfNoUserIsLoggedIn = true;
         }
     }
     $this->boot($proceedIfNoUserIsLoggedIn);
     // Check if the router has the available route and dispatch.
     if ($routingEnabled) {
         return $this->dispatch($request);
     }
     // No route found, so the system proceeds in called entrypoint as fallback.
     return null;
 }
 /**
  * Executes the modules configured via Extbase
  *
  * @param string $moduleName
  * @return Response A PSR-7 response object
  * @throws \RuntimeException
  */
 protected function dispatchModule($moduleName)
 {
     $moduleConfiguration = $this->getModuleConfiguration($moduleName);
     // Check permissions and exit if the user has no permission for entry
     $this->backendUserAuthentication->modAccess($moduleConfiguration, true);
     $id = isset($this->request->getQueryParams()['id']) ? $this->request->getQueryParams()['id'] : $this->request->getParsedBody()['id'];
     if ($id && MathUtility::canBeInterpretedAsInteger($id)) {
         // Check page access
         $permClause = $this->backendUserAuthentication->getPagePermsClause(true);
         $access = is_array(BackendUtility::readPageAccess((int) $id, $permClause));
         if (!$access) {
             throw new \RuntimeException('You don\'t have access to this page', 1289917924);
         }
     }
     /** @var Response $response */
     $response = GeneralUtility::makeInstance(Response::class);
     // Use Core Dispatching
     if (isset($moduleConfiguration['routeTarget'])) {
         $dispatcher = GeneralUtility::makeInstance(Dispatcher::class);
         $this->request = $this->request->withAttribute('target', $moduleConfiguration['routeTarget']);
         $response = $dispatcher->dispatch($this->request, $response);
     } else {
         // extbase module
         $configuration = array('extensionName' => $moduleConfiguration['extensionName'], 'pluginName' => $moduleName);
         if (isset($moduleConfiguration['vendorName'])) {
             $configuration['vendorName'] = $moduleConfiguration['vendorName'];
         }
         // Run Extbase
         $bootstrap = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Core\Bootstrap::class);
         $content = $bootstrap->run('', $configuration);
         $response->getBody()->write($content);
     }
     return $response;
 }
Exemple #27
0
 /**
  * Get the string contents of the view.
  *
  * @return string
  */
 public function render()
 {
     $view = app('view')->file(__DIR__ . '/../../../views/app.blade.php');
     $forum = $this->getForumDocument();
     $data = $this->getDataFromDocument($forum);
     if ($this->actor->exists) {
         $user = $this->getUserDocument();
         $data = array_merge($data, $this->getDataFromDocument($user));
     }
     $view->app = ['preload' => ['data' => $data, 'session' => $this->getSession(), 'document' => $this->document]] + $this->variables;
     $view->bootstrappers = $this->bootstrappers;
     $noJs = array_get($this->request->getQueryParams(), 'nojs');
     $view->title = ($this->title ? $this->title . ' - ' : '') . $forum->data->attributes->title;
     $view->forum = $forum->data;
     $view->layout = app('view')->file($this->layout, ['forum' => $forum->data, 'content' => app('view')->file(__DIR__ . '/../../../views/content.blade.php', ['content' => $this->content, 'noJs' => $noJs, 'forum' => $forum->data])]);
     $view->noJs = $noJs;
     $view->styles = [$this->assets->getCssFile()];
     $view->scripts = [$this->assets->getJsFile()];
     if ($this->localeJs) {
         $view->scripts[] = $this->localeJs->getFile();
     }
     $view->head = implode("\n", $this->headStrings);
     $view->foot = implode("\n", $this->footStrings);
     return $view->render();
 }
 protected function getSourceParams(ServerRequestInterface $request)
 {
     $request_method = $request->getServerParams()['REQUEST_METHOD'];
     switch (strtolower($request_method)) {
         case 'options':
         case 'head':
         case 'get':
             return array_merge($request->getParsedBody(), $request->getQueryParams());
         case 'post':
         case 'put':
         case 'delete':
             return array_merge($request->getQueryParams(), $request->getParsedBody());
         default:
             return [];
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function data(ServerRequestInterface $request, Document $document)
 {
     $id = array_get($request->getQueryParams(), 'id');
     $actor = $request->getAttribute('actor');
     $data = array_get($request->getParsedBody(), 'data');
     return $this->bus->dispatch(new EditLink($id, $actor, $data));
 }
 /**
  * Processes all AJAX calls and sends back a JSON object
  *
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @return ResponseInterface
  */
 public function liveSearchAction(ServerRequestInterface $request, ResponseInterface $response)
 {
     $queryString = $request->getQueryParams()['q'];
     $liveSearch = GeneralUtility::makeInstance(LiveSearch::class);
     $queryParser = GeneralUtility::makeInstance(QueryParser::class);
     $searchResults = array();
     $liveSearch->setQueryString($queryString);
     // Jump & edit - find page and retrieve an edit link (this is only for pages
     if ($queryParser->isValidPageJump($queryString)) {
         $searchResults[] = array_merge($liveSearch->findPage($queryString), ['type' => 'pageJump']);
         $commandQuery = $queryParser->getCommandForPageJump($queryString);
         if ($commandQuery) {
             $queryString = $commandQuery;
         }
     }
     // Search through the database and find records who match to the given search string
     $resultArray = $liveSearch->find($queryString);
     foreach ($resultArray as $resultFromTable) {
         foreach ($resultFromTable as $item) {
             $searchResults[] = $item;
         }
     }
     $response->getBody()->write(json_encode($searchResults));
     return $response;
 }