当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::createFromGlobals方法代码示例

本文整理汇总了PHP中Symfony\Component\HttpFoundation\Request::createFromGlobals方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::createFromGlobals方法的具体用法?PHP Request::createFromGlobals怎么用?PHP Request::createFromGlobals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\HttpFoundation\Request的用法示例。


在下文中一共展示了Request::createFromGlobals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * @param \Silex\Application $app
  */
 public function __construct(Silex\Application $app)
 {
     $this->app = $app;
     $this->db = $app['db'];
     $prefix = $this->app['config']->get('general/database/prefix', 'bolt_');
     // Hashstrength has a default of '10', don't allow less than '8'.
     $this->hashStrength = max($this->app['config']->get('general/hash_strength'), 8);
     $this->usertable = $prefix . 'users';
     $this->authtokentable = $prefix . 'authtoken';
     $this->users = array();
     $this->session = $app['session'];
     /*
      * Get the IP stored earlier in the request cycle. If it's missing we're on CLI so use localhost
      *
      * @see discussion in https://github.com/bolt/bolt/pull/3031
      */
     $request = Request::createFromGlobals();
     $this->hostName = $request->getHost();
     $this->remoteIP = $request->getClientIp() ?: '127.0.0.1';
     $this->userAgent = $request->server->get('HTTP_USER_AGENT');
     $this->authToken = $request->cookies->get('bolt_authtoken');
     // Set 'validsession', to see if the current session is valid.
     $this->validsession = $this->checkValidSession();
     $this->allowed = array('dashboard' => self::EDITOR, 'settings' => self::ADMIN, 'login' => self::ANONYMOUS, 'logout' => self::EDITOR, 'dbcheck' => self::ADMIN, 'dbupdate' => self::ADMIN, 'clearcache' => self::ADMIN, 'prefill' => self::DEVELOPER, 'users' => self::ADMIN, 'useredit' => self::ADMIN, 'useraction' => self::ADMIN, 'overview' => self::EDITOR, 'editcontent' => self::EDITOR, 'editcontent:own' => self::EDITOR, 'editcontent:all' => self::ADMIN, 'contentaction' => self::EDITOR, 'about' => self::EDITOR, 'extensions' => self::DEVELOPER, 'files' => self::EDITOR, 'files:config' => self::DEVELOPER, 'files:theme' => self::DEVELOPER, 'files:uploads' => self::ADMIN, 'translation' => self::DEVELOPER, 'activitylog' => self::ADMIN, 'fileedit' => self::ADMIN);
 }
开发者ID:aaleksu,项目名称:bolt_cm,代码行数:28,代码来源:Users.php

示例2: buildUrl

 /**
  * Builds absolute url address.
  *
  * Example of usage: url('/nmkd/input', array($id));.
  *
  * @param string $uri
  * @param array $params
  * @return string
  */
 public static function buildUrl($uri, $params = array())
 {
     $strParams = '';
     if (!empty($params)) {
         if (strpos($uri, '?') == false) {
             $strParams .= '?';
         } else {
             $strParams .= '&';
         }
         foreach ($params as $param => $val) {
             $strParams .= $param . '=' . $val . '&';
         }
         $strParams = substr($strParams, 0, -1);
     }
     $request = Request::createFromGlobals();
     $protocol = $request->isSecure() ? 'https' : 'http';
     $baseUrl = $request->server->get('SERVER_NAME');
     $doc_root = $request->server->get('DOCUMENT_ROOT');
     $full_path = $request->server->get('SCRIPT_FILENAME');
     $file = basename($request->server->get('SCRIPT_FILENAME'));
     $urlSlug = str_replace($file, '', str_replace($doc_root, '', $full_path));
     $uri = ltrim($uri, '/');
     $urlSlug = ltrim($urlSlug, '/');
     return $protocol . '://' . $baseUrl . '/' . $urlSlug . $uri . $strParams;
 }
开发者ID:vladyslav-p01,项目名称:edu.com,代码行数:34,代码来源:Router.php

示例3: checkAuth

 /**
  * @return bool
  */
 public static function checkAuth()
 {
     $currentCwd = getcwd();
     if (!self::$authenticated) {
         if (!defined('ACP3_ROOT_DIR')) {
             define('ACP3_ROOT_DIR', realpath(__DIR__ . '/../../../../../../../') . '/');
         }
         require_once ACP3_ROOT_DIR . 'vendor/autoload.php';
         $application = new Bootstrap(ApplicationMode::PRODUCTION);
         if ($application->startupChecks()) {
             $symfonyRequest = Request::createFromGlobals();
             $application->initializeClasses($symfonyRequest);
             chdir(ACP3_ROOT_DIR);
             $application->getContainer()->get('core.authentication')->authenticate();
             // if user has access permission...
             if ($application->getContainer()->get('users.model.user_model')->isAuthenticated()) {
                 if (!isset($_SESSION['KCFINDER'])) {
                     $_SESSION['KCFINDER'] = [];
                     $_SESSION['KCFINDER']['disabled'] = false;
                 }
                 // User has permission, so make sure KCFinder is not disabled!
                 $_SESSION['KCFINDER']['disabled'] = false;
                 chdir($currentCwd);
                 self::$authenticated = true;
             }
         }
     }
     chdir($currentCwd);
     return self::$authenticated;
 }
开发者ID:acp3,项目名称:module-filemanager,代码行数:33,代码来源:acp3.php

示例4: __construct

 /**
  * BaseController constructor.
  *
  * @param BaseModel $model Model that will be handled by this Controller
  * @param BaseView $view View that will be rendered by this Controller
  */
 public function __construct(BaseModel $model, BaseView $view)
 {
     $this->model = $model;
     $this->view = $view;
     $this->request = empty(Runner::$request) ? Request::createFromGlobals() : Runner::$request;
     $this->session = new Session($this->request);
 }
开发者ID:spasquier,项目名称:sv-egg-giver,代码行数:13,代码来源:BaseController.php

示例5: dispatch

 public function dispatch()
 {
     $dispatcher = $this->router->getDispatcher();
     $request = Request::createFromGlobals();
     $response = $dispatcher->dispatch($request->getMethod(), $request->getPathInfo());
     return $response->send();
 }
开发者ID:signalfire,项目名称:whatblog,代码行数:7,代码来源:Router.php

示例6: loadUserByUsername

 /**
  * {@inheritdoc}
  */
 public function loadUserByUsername($username, $password = null)
 {
     // if the password is not passed in, we have arrived here from a login form, so grab it from the request
     if (null === $password) {
         $password = Request::createFromGlobals()->get('_password');
     }
     $credentials = array('email' => $username, 'password' => $password);
     $client = $this->irisEntityManager->getClient();
     // use the MAC in the session to access the cached system credentials
     $authData = $this->session->get('auth-data');
     if (!$client->hasValidCredentials($authData->get('systemKey'), $authData->get('systemSecret'))) {
         throw new BadCredentialsException('Invalid System credentials for IRIS');
     }
     // attempt to authenticate and get the Landlords key and secret
     if (false === ($oauthCredentials = $client->assume($credentials))) {
         // invalid credentials
         throw new UsernameNotFoundException('Invalid Landlord credentials for IRIS');
     }
     // create the User to return it to be stored in the session
     $user = new LandlordUser($authData->get('systemKey'), $authData->get('systemSecret'), $username, $password);
     // manually set the consumer key and secret as the username and password do not represent them
     $user->setConsumerKey($oauthCredentials['consumerKey']);
     $user->setConsumerSecret($oauthCredentials['consumerSecret']);
     return $user;
 }
开发者ID:AlexEvesDeveloper,项目名称:hl-stuff,代码行数:28,代码来源:LandlordUserProvider.php

示例7: getRequest

 /**
  * Get Request either from the container or else create it from globals.
  *
  * @return \Symfony\Component\HttpFoundation\Request
  */
 protected function getRequest()
 {
     if ($this->getContainer()->isRegistered('Symfony\\Component\\HttpFoundation\\Request') || $this->getContainer()->isInServiceProvider('Symfony\\Component\\HttpFoundation\\Request')) {
         return $this->getContainer()->get('Symfony\\Component\\HttpFoundation\\Request');
     }
     return Request::createFromGlobals();
 }
开发者ID:lineldcosta,项目名称:route,代码行数:12,代码来源:AbstractStrategy.php

示例8: processView

 protected function processView()
 {
     $this->preProcessView();
     $themeSettings = Container::get('theme_settings');
     $request = Request::createFromGlobals();
     /*if ($request->isXmlHttpRequest()) {
                 if ($request->request->has('ajaxData')) {
                     $ajaxData = $request->request->get('ajaxData');
                     if (isset($ajaxData['component']) && isset($ajaxData['block'])) {
                         $themeSettings = $themeSettings['items'][$ajaxData['block']][$ajaxData['component']];
                         $globalTemplateData = array(
                             'errors' => $this->errors,
                         );
     
                         $globalTemplateData = array_merge_recursive(
                             $globalTemplateData,
                             $themeSettings
                         );
                         return $globalTemplateData;
                     }
                 }
             }*/
     $globalTemplateData = array('errors' => $this->errors);
     $globalTemplateData = array_merge_recursive($globalTemplateData, $themeSettings);
     //dynamic template data, wich uses in all templates (many templates)
     //menu data, sidebar data, etc
     return $globalTemplateData;
 }
开发者ID:vladyslav-p01,项目名称:edu.com,代码行数:28,代码来源:Controller.php

示例9: handleRequest

 /**
  * Apply the request filters, call the front controller and returns a Response
  *
  * @param string $path
  * @return Response
  * @throws \Exception
  */
 private function handleRequest($path)
 {
     try {
         // Create a request object
         $request = Request::createFromGlobals();
         // Decode the path and add the params to the request
         $controllerActionParams = $this->router->decode($path);
         $request->query->add($controllerActionParams->params);
         // Apply optional filters on the Request
         if ($this->provider->has('request.filters')) {
             foreach ($this->provider->lookup('request.filters') as $filter) {
                 // The request filter can return a Response. If it does, the controller won't be called
                 /** @var $filter RequestFilter */
                 $response = $filter->apply($request);
                 if ($response instanceof Response) {
                     return $response;
                 }
             }
         }
         // Execute the appropriate controller/action
         $controller = $this->provider->create($controllerActionParams->controller, $request);
         return $controller->handle($controllerActionParams->action);
     } catch (\Exception $e) {
         // Check if we have an exception controller
         if (!$this->provider->has('exception.controller')) {
             throw $e;
         }
         $exceptionController = $this->provider->lookup('exception.controller');
         return $exceptionController->handle($e);
     }
 }
开发者ID:mystlabs,项目名称:mistyapp,代码行数:38,代码来源:FrontController.php

示例10: indexAction

 /**
  * Initializes the Contao framework.
  *
  * @return InitializeControllerResponse
  *
  * @Route("/_contao/initialize", name="contao_initialize")
  */
 public function indexAction()
 {
     @trigger_error('Custom entry points are deprecated and will no longer work in Contao 5.0.', E_USER_DEPRECATED);
     $masterRequest = $this->get('request_stack')->getMasterRequest();
     $realRequest = Request::createFromGlobals();
     $scope = ContaoCoreBundle::SCOPE_FRONTEND;
     if (defined('TL_MODE') && 'BE' === TL_MODE) {
         $scope = ContaoCoreBundle::SCOPE_BACKEND;
     }
     // Necessary to generate the correct base path
     foreach (['REQUEST_URI', 'SCRIPT_NAME', 'SCRIPT_FILENAME', 'PHP_SELF'] as $name) {
         $realRequest->server->set($name, str_replace(TL_SCRIPT, 'app.php', $realRequest->server->get($name)));
     }
     $realRequest->attributes->replace($masterRequest->attributes->all());
     // Initialize the framework with the real request
     $this->get('request_stack')->push($realRequest);
     if (method_exists('Symfony\\Component\\DependencyInjection\\Container', 'enterScope')) {
         $this->container->enterScope($scope);
     }
     $this->container->get('contao.framework')->initialize();
     // Add the master request again. When Kernel::handle() is finished,
     // it will pop the current request, resulting in the real request being active.
     $this->get('request_stack')->push($masterRequest);
     return new InitializeControllerResponse('', 204);
 }
开发者ID:qzminski,项目名称:contao-core-bundle,代码行数:32,代码来源:InitializeController.php

示例11: __construct

 public function __construct(UnderlyingRequest $request = null)
 {
     $request = $request ?: UnderlyingRequest::createFromGlobals();
     $this->URI = $request->getPathInfo();
     $this->referrer = $request->server->get('HTTP_REFERER');
     parent::__construct($this->base($request), $this->attributes($request));
 }
开发者ID:lionar,项目名称:http,代码行数:7,代码来源:Request.php

示例12: editAction

 public function editAction($id, $threadid, $postid)
 {
     $request = Request::createFromGlobals();
     $em = $this->getDoctrine()->getManager();
     $user = $this->get('security.context')->getToken()->getUser();
     # get thread and validate
     $post = $em->getRepository('MaximModuleForumBundle:Post')->findOneBy(array("id" => $postid));
     if (!$post) {
         throw $this->createNotFoundException("Could not find the requested post");
     }
     if ($post->getCreatedBy()->getId() != $user->getId()) {
         throw new AccessDeniedException("You are not allowed to edit this post");
     }
     # create form
     $postedit = new PostEdit($post, $user);
     $form = $this->createForm(new PostEditType(), $postedit);
     # handle form
     $form->handleRequest($request);
     if ($form->isValid()) {
         $postedit = $form->getData();
         $em->flush();
         $this->get('session')->getFlashBag()->add('notice', 'Your post has been updated!');
         return $this->redirect($this->generateUrl('forum_thread_view', array('id' => $post->getThread()->getForum()->getId(), 'threadid' => $post->getThread()->getId())));
     }
     # set vars
     $data['form'] = $form->createView();
     $data['post'] = $post;
     return $this->render('MaximCMSBundle:Forum:editPost.html.twig', $data);
 }
开发者ID:c4d3r,项目名称:mcsuite-application-eyeofender,代码行数:29,代码来源:PostController.php

示例13: __construct

 public function __construct()
 {
     $this['app_version'] = "1.0";
     // property injection
     $this['request'] = Request::createFromGlobals();
     // static method injection
 }
开发者ID:phpcrazy,项目名称:wpa22,代码行数:7,代码来源:Application.php

示例14: __construct

 public function __construct(StorageInterface $storage, Options $options, Request $request = null, IpTransformer $ip_transformer = null)
 {
     $this->storage = $storage;
     $this->options = $options;
     $this->request = $request ? $request : Request::createFromGlobals();
     $this->ip_transformer = $ip_transformer ? $ip_transformer : new IpTransformer();
 }
开发者ID:polycademy,项目名称:polyauth,代码行数:7,代码来源:LoginAttempts.php

示例15: createFromGlobals

 /**
  * Creates a new request with values from PHP's super globals. 
  * Overwrite to fix an apache header bug. Read more here:
  * http://stackoverflow.com/questions/11990388/request-headers-bag-is-missing-authorization-header-in-symfony-2%E2%80%94
  *
  * @return Request A new request
  *
  * @api
  */
 public static function createFromGlobals()
 {
     $request = parent::createFromGlobals();
     //fix the bug.
     self::fixAuthHeader($request->headers);
     return $request;
 }
开发者ID:vzailskas,项目名称:oauth2-server-httpfoundation-bridge,代码行数:16,代码来源:Request.php


注:本文中的Symfony\Component\HttpFoundation\Request::createFromGlobals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。