getUri() public method

Generates a normalized URI (URL) for the Request.
See also: getQueryString()
public getUri ( ) : string
return string A normalized URI (URL) for the Request
 /**
  * On kernel response event
  *
  * @param FilterResponseEvent $event
  */
 public function onKernelResponse(FilterResponseEvent $event)
 {
     // Only master request and 200 OK are processed
     if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType() && $event->getResponse()->isOk()) {
         $route = $this->router->match($this->request->getPathInfo());
         // Ignore internal route
         if (0 === stripos($route['_route'], '_')) {
             return;
         }
         $this->session->set('_unifik.last_master_request_uri', $this->request->getUri());
         $this->session->set('_unifik.last_master_request_route', $route);
     }
 }
 /**
  * Creates and persists a thread with the specified id.
  *
  * @param mixed $id
  * @return ThreadInterface
  */
 public function create($id)
 {
     $thread = $this->threadManager->createThread();
     $thread->setId($id);
     $thread->setPermalink($this->request->getUri());
     $this->threadManager->addThread($thread);
     return $thread;
 }
 /**
  * @param string $collectorName
  *
  * @return RequestObject
  */
 public function createFromRequest($collectorName)
 {
     $requestObject = new RequestObject();
     $requestObject->setHeaders($this->request->headers->all());
     $requestObject->setPostParameters($this->request->request->all());
     $requestObject->setQueryParameters($this->request->query->all());
     $requestObject->setContent($this->request->getContent());
     $requestObject->setCollector($collectorName);
     $requestObject->setUri($this->request->getUri());
     $requestObject->setMethod($this->request->getMethod());
     return $requestObject;
 }
 protected function setTargetPath(Request $request)
 {
     // Ne conservez pas de chemin cible pour les requêtes XHR et non-GET
     // Vous pouvez ajouter n'importe quelle logique supplémentaire ici
     // si vous le voulez
     if ($request->isXmlHttpRequest() || 'GET' !== $request->getMethod()) {
         return;
     }
     $session = $request->getSession();
     $session->set('_security.target_path', $request->getUri());
     $session->getFlashBag()->add('info', $request->getUri());
     return $this->redirect($this->generateUrl('heliosblog_accueil', array('blog' => $request->get('blog'))));
 }
 public function onAuthenticationSuccess(Request $request, TokenInterface $token)
 {
     // If the user tried to access a protected resource and was forces to login
     // redirect him back to that resource
     if ($this->container->get('security.context')->isGranted('ROLE_SUPER_ADMIN') || $token->getUser()->hasRole('ROLE_ADMIN')) {
         $refererUri = $request->getSession()->get('_security.target_path');
         $url = $refererUri && $refererUri != $request->getUri() ? $refererUri : $this->router->generate('sonata_admin_dashboard');
     } else {
         $refererUri = $request->getSession()->get('_security.target_path');
         $url = $refererUri && $refererUri != $request->getUri() ? $refererUri : $this->router->generate('app_frontend_homepage');
     }
     return new RedirectResponse($url);
 }
Beispiel #6
0
 /**
  * Get the request formatted as meta data.
  *
  * @return array
  */
 public function getMetaData()
 {
     $data = [];
     $data['url'] = $this->request->getUri();
     $data['httpMethod'] = $this->request->getMethod();
     $data['params'] = $this->getInput() + $this->request->query->all();
     $data['clientIp'] = $this->request->getClientIp();
     if ($agent = $this->request->headers->get('User-Agent')) {
         $data['userAgent'] = $agent;
     }
     if ($headers = $this->request->headers->all()) {
         $data['headers'] = $headers;
     }
     return ['request' => $data];
 }
 /**
  * {@inheritDoc}
  */
 public function execute($request)
 {
     /** @var $request GetHttpRequest */
     RequestNotSupportedException::assertSupports($this, $request);
     if (false == $this->httpRequest) {
         return;
     }
     $request->query = $this->httpRequest->query->all();
     $request->request = $this->httpRequest->request->all();
     $request->headers = $this->httpRequest->headers->all();
     $request->method = $this->httpRequest->getMethod();
     $request->uri = $this->httpRequest->getUri();
     $request->clientIp = $this->httpRequest->getClientIp();
     $request->userAgent = $this->httpRequest->headers->get('User-Agent');
 }
Beispiel #8
0
 public function run()
 {
     $this->log('Processing uri: ' . $this->req->getUri());
     try {
         foreach ($this->middleware as $middleware) {
             $middleware->handle($this->req, $this->res);
         }
     } catch (\Exception $e) {
         $this->log($e->getMessage(), [], LogLevel::ERROR);
         foreach ($this->onException as $exceptionCallback) {
             call_user_func($exceptionCallback, $e);
         }
     }
     $this->log('Processed uri: ' . $this->req->getUri());
 }
Beispiel #9
0
 /**
  * @param Request $request
  * @param Application $app
  * 
  * @return mixed
  */
 public function ver(Request $request, Application $app)
 {
     $archivo = $request->get('archivo');
     if (!empty($archivo)) {
         #$file    = fopen($archivo, 'r');
         #$content = fread($file, 8192);
         #fclose($file);
         $contenido = file_get_contents($archivo);
         return $app['twig']->render('backend/archivo/content.html.twig', array('content' => $contenido));
     } else {
         $explorer = $app['explorer'];
         if (strstr($request->getUri(), "protected") && $app['security']->isGranted('ROLE_SUPER_ADMIN')) {
             $files = array();
             $filesProtected = $explorer->getFilesProtected();
         } else {
             $files = $explorer->getFiles();
             if ($app['security']->isGranted('ROLE_SUPER_ADMIN')) {
                 $filesProtected = $explorer->getFilesProtected();
             } else {
                 $filesProtected = array();
             }
         }
         return $app['twig']->render('backend/archivo/list.html.twig', array('rows' => $files, 'rows_protected' => $filesProtected));
     }
 }
Beispiel #10
0
 /**
  * @param Request $request
  * @param $mode
  * @param null $securekey
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  */
 private function crud(Request $request, $mode, $securekey = null)
 {
     $locale = $request->getLocale();
     $defaultLocale = $this->container->getParameter("SSone.default_locale");
     $em = $this->getDoctrine()->getManager();
     $ls = $this->get('ssone.cms.Localiser');
     $altLinks = $ls->getAltAdminLangLinks($request->getUri());
     if ($mode == "new") {
         $module = new Module();
     } else {
         $module = $this->getDoctrine()->getRepository('SSoneCMSBundle:Module')->findBySecurekey($securekey);
     }
     $contentService = $this->get('ssone.cms.content');
     $form = $this->createForm(new ModuleTYPE($em, $contentService, $locale), $module);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $this->get('ssone.cms.recordauditor')->auditRecord($module);
         $uploader = $this->get('ssone.cms.fileuploader');
         if ($form['file_templatePath']->getData() && ($fp = $uploader->templateUpload($form['file_templatePath']->getData(), "module"))) {
             $module->setTemplatePath($fp);
         }
         switch ($mode) {
             case "new":
                 $em->persist($module);
                 break;
             case "delete":
                 $em->remove($module);
                 break;
         }
         $em->flush();
         return $this->redirect($this->generateUrl('ssone_cms_admin_modules_list'));
     }
     return $this->render('SSoneCMSBundle:Module:crud.html.twig', array('form' => $form->createView(), 'menuItemTitle' => $module->getName($defaultLocale), 'mode' => $mode, 'locale' => $locale, 'altLinks' => $altLinks));
 }
  /**
   * @param Request $request The request containing the query string to parse.
   * @return array
   *
   * @todo: Maybe this should return a FillPdfLinkContext object or something?
   *   Guess it depends on how much I end up needing to change it.
   */
  public function parseRequest(Request $request) {
    // @todo: Use Url::fromRequest when/if it lands in core. See https://www.drupal.org/node/2605530
    $path = $request->getUri();
    $request_url = $this->createUrlFromString($path);

    return $this->parseLink($request_url);
  }
Beispiel #12
0
 /**
  * Constructor.
  *
  * NOTE:
  * For security reasons we don't store the request object here so the
  * values in the event remain immutable.
  *
  * @param Request $request
  */
 public function __construct(Request $request)
 {
     $this->clientIp = $request->getClientIp();
     $this->dateTime = $request->server->get('REQUEST_TIME');
     $this->uri = $request->getUri();
     $this->userName = $request->request->get('username');
 }
 /**
  * {@inheritdoc}
  */
 public function process(Request $request, RequestAttributes $requestAttributes)
 {
     $portalInformation = $requestAttributes->getAttribute('portalInformation');
     if (!$portalInformation instanceof PortalInformation) {
         return new RequestAttributes();
     }
     $attributes = ['requestUri' => $request->getUri()];
     if (null !== ($localization = $portalInformation->getLocalization())) {
         $request->setLocale($localization->getLocalization());
     }
     $attributes['portalInformation'] = $portalInformation;
     $attributes['getParameter'] = $request->query->all();
     $attributes['postParameter'] = $request->request->all();
     $attributes['matchType'] = $portalInformation->getType();
     $attributes['redirect'] = $portalInformation->getRedirect();
     $attributes['analyticsKey'] = $portalInformation->getAnalyticsKey();
     $attributes['portalUrl'] = $portalInformation->getUrl();
     $attributes['webspace'] = $portalInformation->getWebspace();
     $attributes['portal'] = $portalInformation->getPortal();
     if ($portalInformation->getType() === RequestAnalyzerInterface::MATCH_TYPE_REDIRECT) {
         return new RequestAttributes($attributes);
     }
     $attributes['localization'] = $portalInformation->getLocalization();
     $attributes['segment'] = $portalInformation->getSegment();
     list($resourceLocator, $format) = $this->getResourceLocatorFromRequest($portalInformation, $request);
     $attributes['urlExpression'] = $portalInformation->getUrlExpression();
     $attributes['resourceLocator'] = $resourceLocator;
     $attributes['format'] = $format;
     $attributes['resourceLocatorPrefix'] = substr($portalInformation->getUrl(), strlen($request->getHttpHost()));
     if (null !== $format) {
         $request->setRequestFormat($format);
     }
     return new RequestAttributes($attributes);
 }
 /**
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function indexAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $params = $request->get('search');
     $vertical = NULL;
     /* SEO */
     $url_parsed = parse_url($request->getUri());
     $url_path = $url_parsed['path'];
     if (isset($url_parsed['query'])) {
         $url_path .= '?' . $url_parsed['query'];
     }
     $post_parameters = $this->getPostParameters($request);
     $adSearchUrl = $this->get('rmc_core.ad_search_url_service');
     $adSearchUrl->parseUrl($url_path, $post_parameters);
     $urlFilters = $adSearchUrl->getFilters();
     $niceUrl = $adSearchUrl->getNiceUrlByFilters($urlFilters);
     $filters = $adSearchUrl->getNiceFilters();
     // redirect to smart url
     if ($adSearchUrl->is302 && $niceUrl != '/') {
         return $this->redirect($this->container->get('kernel')->getEnvironment() == 'dev' ? '/app_dev.php' . $niceUrl : $niceUrl);
     }
     //print_r($filters);exit;
     //echo 'NICE URL '.$adSearchUrl->getNiceUrlAdding(array('category1' => 2), $filters);
     if (isset($filters['vertical'])) {
         $vertical = $em->getRepository('Entity:Vertical')->find($filters['vertical']);
     }
     $searchManager = AdSearchFactory::getSearchManager($this->container, $vertical ? $vertical->getCode() : '');
     // choose based on search parameter otherwise use 'Ad'
     $filters['select'] = array('id');
     $filters['facet'] = true;
     // display the total number of documents found by solr
     $query = $searchManager->getSolrSearchService()->getQueryByCriteria($filters, NULL, true);
     $solrRegistry = $this->get('solarium.client_registry');
     $client = $solrRegistry->getClient('rmcslave');
     $pager = array($client, $query);
     $paginator = $this->get('knp_paginator');
     $resultset = $paginator->paginate($pager, $request->get('page', 1), $request->get('page_range', 10));
     $resultsetFacet = $resultset->getCustomParameter('result');
     $documents = $resultset->getItems();
     $data = $resultset->getPaginationData();
     $facets = $searchManager->getSolrSearchService()->getFacetFields($resultsetFacet);
     $facetBuilder = new AdSearchFacetBulderService($this->getDoctrine()->getManager(), $facets, $adSearchUrl);
     $niceFacets = $facetBuilder->getNiceFacets();
     //print_r($niceFacets);exit;
     //echo $documents->getTotalItemCount();exit;
     //echo 'NumFound: '.$resultset->getNumFound();exit;
     /*
             foreach ($documents as $doc)
             {
                 echo 'ID '.$doc->id."<br />";
             }*/
     $ids = RmcHelpers::getPrimaryKeys($documents);
     $ads = $em->getRepository('Entity:Ad')->findById($ids);
     $noLayout = $request->headers->get('X-PJAX') ? true : false;
     if ($noLayout) {
         return $this->render('RmcCoreAdSearchBundle:Default:pjaxIndex.html.twig', array('ads' => $ads, 'documents' => $documents, 'paginator' => $resultset, 'facetFields' => $niceFacets, 'noLayout' => $noLayout));
     } else {
         return $this->render('RmcCoreAdSearchBundle:Default:index.html.twig', array('ads' => $ads, 'documents' => $documents, 'paginator' => $resultset, 'facetFields' => $niceFacets, 'noLayout' => $noLayout));
     }
 }
 /**
  * @param Request $request
  * @param $mode
  * @param null $securekey
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  */
 private function crud(Request $request, $mode, $securekey = null)
 {
     $locale = $request->getLocale();
     $defaultLocale = $this->container->getParameter("SSone.default_locale");
     $em = $this->getDoctrine()->getManager();
     $ls = $this->get('ssone.cms.Localiser');
     $altLinks = $ls->getAltAdminLangLinks($request->getUri());
     if ($mode == "new") {
         $menuItem = new MenuItem();
     } else {
         $menuItem = $this->getDoctrine()->getRepository('SSoneCMSBundle:MenuItem')->findBySecurekey($securekey);
     }
     $contentLibrary = $this->get('ssone.cms.content')->getAllForGroupedChoiceOptions();
     $fieldsRepository = $this->getDoctrine()->getRepository('SSoneCMSBundle:Field');
     $menuItems = $this->get('ssone.cms.navigation');
     $menuItems = $menuItems->buildFlatNavigationArray($menuItem->getId());
     $form = $this->createForm(new MenuItemTYPE($request->getLocale(), $mode, $contentLibrary, $menuItems, $fieldsRepository), $menuItem);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $this->handleParentChoice($menuItem, $em);
         $this->handleContentChoice($menuItem, $em);
         $this->get('ssone.cms.recordauditor')->auditRecord($menuItem);
         switch ($mode) {
             case "new":
                 $em->persist($menuItem);
                 break;
             case "delete":
                 $em->remove($menuItem);
                 break;
         }
         $em->flush();
         return $this->redirect($this->generateUrl('ssone_cms_admin_menuItems_list'));
     }
     return $this->render('SSoneCMSBundle:MenuItem:crud.html.twig', array('form' => $form->createView(), 'menuItemTitle' => $menuItem->getName($defaultLocale), 'mode' => $mode, 'locale' => $locale, "altLinks" => $altLinks));
 }
Beispiel #16
0
 protected function createAuthRequest(Request $request, HttpResponse $response, $username, $password)
 {
     if ($params = $this->fetchAuthParams($request->getUri(), $response, $username, $password)) {
         return QueryFixRequest::create($params['url'], $params['method'], array(), array(), array(), array(), http_build_query($params['params'], '', '&'));
     }
     return false;
 }
 /**
  * Execute barebones JSON middleware request
  */
 protected static function executeRequest(Request $request)
 {
     if (testAdapter == 'HTTP') {
         $uri = str_replace('http://localhost', testHttpUri, $request->getUri());
         $response = static::$adapter->send($request, $uri);
         self::$mem = 0;
     } else {
         self::$mem = memory_get_peak_usage();
         $response = self::$app->handle($request);
         self::$mem = memory_get_peak_usage() - self::$mem;
     }
     if (self::$debug) {
         echo "\nRequest: " . ($method = $request->getMethod()) . ' ' . $request->getUri() . "\n";
         if ($method == 'POST') {
             echo "Content: " . $request->getContent() . "\n";
         }
     }
     // always provide normal Response to test cases
     if ($response instanceof StreamedResponse) {
         ob_start();
         $response->sendContent();
         $content = ob_get_contents();
         ob_end_clean();
         $response = Response::create($content, $response->getStatusCode(), $response->headers->all());
     }
     if (self::$debug) {
         echo "\nResponse: " . $response . "\n";
     }
     return $response;
 }
 /**
  * @param Request $request
  * @param $mode
  * @param null $securekey
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function editAction(Request $request, $mode, $securekey = null)
 {
     $locale = $request->getLocale();
     $em = $this->getDoctrine()->getManager();
     $fieldsRepository = $this->getFieldsRepository();
     $contentService = $this->get('ssone.cms.content');
     $blockService = $this->get('ssone.cms.block');
     $ls = $this->get('ssone.cms.Localiser');
     $altLinks = $ls->getAltAdminLangLinks($request->getUri());
     $contentType = $this->getDoctrine()->getRepository('SSoneCMSBundle:ContentType')->findBySecurekey($securekey);
     //Add/Remove blocks as necessary
     $blockService->contentTypeBlockManager($contentType);
     $form = $this->createForm(new ContentTypeAttributesTYPE($mode, $fieldsRepository, $contentService, $locale), $contentType);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $auditor = $this->get('ssone.cms.recordauditor');
         $auditor->auditRecord($contentType);
         //Audit blocks and fields
         foreach ($contentType->getBlocks() as $block) {
             $auditor->auditRecord($block);
             foreach ($block->getBlockFields() as $blockField) {
                 $auditor->auditRecord($blockField);
             }
         }
         $blockService->handleUploadBlocks($form);
         $em->flush();
         return $this->redirect($this->generateUrl('ssone_cms_admin_content_list'));
     }
     return $this->render('SSoneCMSBundle:Content:crud.html.twig', array('form' => $form->createView(), 'contentTitle' => $contentType->getName(), 'mode' => $mode, 'locale' => $locale, "altLinks" => $altLinks));
 }
 /**
  * @param \Exception $exception
  * @param \Symfony\Component\HttpFoundation\Request $request
  */
 public function notifyOnException(Exception $exception, Request $request = null)
 {
     /**
      * Display the URL where the exception is thrown
      */
     if ($request) {
         $body = sprintf("%s: %s\r\n\r\n", $this->application, $request->getUri());
     } else {
         $body = sprintf("%s\r\n\r\n", $this->application);
     }
     /**
      * Display the exception
      */
     $class = explode("\\", get_class($exception));
     $body .= sprintf("%s: %s\r\nOn %s:%s\r\n\r\n", end($class), $exception->getMessage(), $exception->getFile(), $exception->getLine());
     /**
      * Display the previous exceptions
      */
     $previous = $exception;
     while (null !== ($previous = $previous->getPrevious())) {
         $class = explode("\\", get_class($previous));
         $body .= sprintf("%s: %s\r\nOn %s:%s\r\n\r\n", end($class), $previous->getMessage(), $previous->getFile(), $previous->getLine());
     }
     /**
      * Display the trace
      */
     $body .= $exception->getTraceAsString();
     $this->speak($body, 'PasteMessage');
 }
 /**
  * @Route(name="user_admin_security_login", path="admin/login")
  * @param Request $request
  * @return Response|RedirectResponse
  */
 public function loginAction(Request $request)
 {
     $user = $this->getUser();
     if ($user instanceof UserInterface) {
         $this->get('session')->getFlashBag()->set('sonata_user_error', 'sonata_user_already_authenticated');
         $url = $this->generateUrl('sonata_admin_dashboard');
         return $this->redirect($url);
     }
     $session = $request->getSession();
     // get the error if any (works with forward and redirect -- see below)
     if ($request->attributes->has(Security::AUTHENTICATION_ERROR)) {
         $error = $request->attributes->get(Security::AUTHENTICATION_ERROR);
     } elseif (null !== $session && $session->has(Security::AUTHENTICATION_ERROR)) {
         $error = $session->get(Security::AUTHENTICATION_ERROR);
         $session->remove(Security::AUTHENTICATION_ERROR);
     } else {
         $error = '';
     }
     if ($error) {
         // TODO: this is a potential security risk (see http://trac.symfony-project.org/ticket/9523)
         $error = $error->getMessage();
     }
     // last username entered by the user
     $lastUsername = null === $session ? '' : $session->get(Security::LAST_USERNAME);
     $csrfToken = $this->get('security.csrf.token_manager')->getToken('authenticate');
     if ($this->get('security.authorization_checker')->isGranted('ROLE_ADMIN')) {
         $refererUri = $request->server->get('HTTP_REFERER');
         return $this->redirect($refererUri && $refererUri != $request->getUri() ? $refererUri : $this->generateUrl('sonata_admin_dashboard'));
     }
     return $this->render('UserBundle:Admin:Security/login.html.twig', array('last_username' => $lastUsername, 'error' => $error, 'csrf_token' => $csrfToken, 'base_template' => $this->get('sonata.admin.pool')->getTemplate('layout'), 'admin_pool' => $this->get('sonata.admin.pool')));
 }
 public function onException(BlockadeException $exception, Request $request)
 {
     $driver = $exception->getDriver();
     $msg = $driver ? get_class($driver) . ' threw ' : '';
     $msg .= sprintf('%s with message "%s" from ip %s on page %s', get_class($exception), $exception->getMessage(), $request->getClientIp(), $request->getUri());
     $this->logger->log($this->level, $msg);
 }
 public function authAction(Request $request, Application $app)
 {
     if ($app['session']->get('twitter_oauth_token') === null) {
         // get the request token
         $reply = $app['twitter']->oauth_requestToken(['oauth_callback' => $request->getUri()]);
         if (empty($reply)) {
             return new Response('Reply is empty');
         }
         // store the token
         $app['twitter']->setToken($reply->oauth_token, $reply->oauth_token_secret);
         $app['session']->set('twitter_oauth_token', $reply->oauth_token);
         $app['session']->set('twitter_oauth_token_secret', $reply->oauth_token_secret);
         $app['session']->set('twitter_oauth_verify', true);
         // redirect to auth website
         return $app->redirect($app['twitter']->oauth_authorize());
     } elseif ($request->get('oauth_verifier') !== null && $app['session']->get('twitter_oauth_verify') !== null) {
         // verify the token
         $app['twitter']->setToken($app['session']->get('twitter_oauth_token'), $app['session']->get('twitter_oauth_token_secret'));
         $app['session']->set('twitter_oauth_verify', null);
         // get the access token
         $reply = $app['twitter']->oauth_accessToken(['oauth_verifier' => $request->get('oauth_verifier')]);
         // store the token (which is different from the request token!)
         $app['session']->set('twitter_oauth_token', $reply->oauth_token);
         $app['session']->set('twitter_oauth_token_secret', $reply->oauth_token_secret);
         // send to same URL, without oauth GET parameters
         return $app->json(['oauth_token' => $reply->oauth_token, 'oauth_token_secret' => $reply->oauth_token_secret]);
     }
     return new Response('oops');
 }
 /**
  * {@inheritDoc}
  */
 public function collect(Request $request, Response $response, \Exception $exception = null)
 {
     $data = [];
     /** @var RequestInterface $request */
     foreach ($this->history as $request) {
         $transaction = $this->history[$request];
         /** @var ResponseInterface $response */
         $response = $transaction['response'];
         $error = $transaction['error'];
         $info = $transaction['info'];
         $req = ['request' => ['method' => $request->getMethod(), 'version' => $request->getProtocolVersion(), 'headers' => $request->getHeaders(), 'body' => $this->cropContent($request->getBody())], 'info' => $info, 'uri' => urldecode($request->getUri())];
         if ($response) {
             $req['response'] = ['reasonPhrase' => $response->getReasonPhrase(), 'headers' => $response->getHeaders(), 'body' => $this->cropContent($response->getBody())];
         }
         $req['httpCode'] = $response ? $response->getStatusCode() : 0;
         if ($error) {
             $req['error'] = ['message' => $error->getMessage(), 'line' => $error->getLine(), 'file' => $error->getFile(), 'code' => $error->getCode(), 'trace' => $error->getTraceAsString()];
         }
         if ($response && $response->hasHeader('X-Guzzle-Cache')) {
             $req['cache'] = $response->getHeaderLine('X-Guzzle-Cache');
         }
         $data[] = $req;
     }
     $this->data = $data;
 }
Beispiel #24
0
 /**
  * {@inheritdoc}
  */
 protected function doEnhance(CustomUrlBehavior $customUrl, Webspace $webspace, array $defaults, Request $request)
 {
     if (substr($request->getRequestUri(), -5, 5) !== '.html') {
         return [];
     }
     return ['_finalized' => true, '_controller' => 'SuluWebsiteBundle:Default:redirect', 'url' => substr($request->getUri(), 0, -5)];
 }
Beispiel #25
0
 /**
  * @param $user
  * @param $pass
  *
  * @return bool
  */
 public function checkUserPassword($user, $pass)
 {
     if (isset($user) && isset($pass)) {
         $pass = md5($pass);
         return $this->login($user, $pass);
     }
     $user = $this->session->get('user');
     $pass = $this->session->get('pass');
     if (!isset($user) && !isset($pass)) {
         $this->invaliateSession();
         return false;
     }
     if (strpos(strtoupper($this->request->getUri()), 'DESCARGA') > 0 && $this->session->get('nivel') != 2) {
         return false;
     }
     return true;
 }
Beispiel #26
0
 public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
 {
     $url = $request->getUri();
     if (strpos($url, 'index.php') !== FALSE) {
         return $this->legacyKernel->handle($request, $type, $catch);
     }
     return $this->httpKernel->handle($request, $type, $catch);
 }
Beispiel #27
0
 /**
  * Provide the install.html file.
  *
  * @param Request $request The request to process.
  *
  * @return Response
  */
 public function installAction(Request $request)
 {
     // Special case, already setup. Redirect to index then.
     if ($this->isInstalled()) {
         return new RedirectResponse($request->getUri() . 'index.html');
     }
     return new Response(str_replace('var TENSIDEApi=window.location.href.split(\'#\')[0];', 'var TENSIDEApi=\'' . $request->getSchemeAndHttpHost() . $request->getBaseUrl() . '/\';', file_get_contents($this->getAssetsDir() . '/install.html')), 200, ['Content-Type' => 'text/html; charset=UTF-8']);
 }
Beispiel #28
0
 /**
  * @param \RecursiveArrayIterator $iterator
  * @return mixed
  * @throws \Symfony\Component\HttpKernel\Exception\HttpException
  */
 protected function buildResources(\RecursiveArrayIterator $iterator)
 {
     if (count($this->mapping) == 0) {
         throw new HttpException(Codes::HTTP_BAD_REQUEST, 'Unable to generate CMMI Data, no mapping is known');
     }
     $this->resource = new Resource(new Link($this->request->getUri(), 'self'));
     if ($iterator->hasChildren()) {
         while ($iterator->valid()) {
             $childItem = $iterator->current();
             $this->addResource(new \RecursiveArrayIterator($childItem));
             $iterator->next();
         }
     } else {
         $this->addResource($iterator);
     }
     return $this->resource;
 }
Beispiel #29
0
 protected function setTargetPath(Request $request)
 {
     if ($request->isXmlHttpRequest()) {
         return;
     }
     if ($request->hasSession() && ($request->isMethodSafe() || $request->get('_route') == 'engishop_front_cart_add')) {
         $request->getSession()->set('_security.' . $this->providerKey . '.target_path', $request->getUri());
     }
 }
Beispiel #30
-1
 /**
  *
  * @param Request $request
  * @throws AppException
  * @return ApplicationUri
  */
 public function match($request)
 {
     $found = null;
     $uris = ApplicationUriQuery::create()->joinApplication()->filterByHttphost($request->getHttpHost())->find();
     $requestUri = Text::create($request->getRequestUri())->trimRight('/');
     foreach ($uris as $uri) {
         $basepath = new Text($uri->getBasepath());
         // either request uri and uri basepath are both empty
         // or request uri starts with basepath
         if ($basepath->isEmpty() && $uri->getHttphost() == $request->getHttpHost() || $requestUri->startsWith($basepath)) {
             // assign when it's the first found
             if ($found === null) {
                 $found = $uri;
             } else {
                 if ($basepath->count('/') > Text::create($found->getBasepath())->count('/')) {
                     $found = $uri;
                 }
             }
         }
     }
     if ($found === null) {
         throw new AppException(sprintf('No app found on %s', $request->getUri()), 404);
     }
     $this->destination = str_replace($found->getBasepath(), '', $request->getRequestUri());
     return $found;
 }