本文整理汇总了PHP中Thelia\Core\HttpFoundation\Request类的典型用法代码示例。如果您正苦于以下问题:PHP Request类的具体用法?PHP Request怎么用?PHP Request使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Request类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
protected function setUp()
{
$this->controller = $controller = $this->getMock("Thelia\\Controller\\BaseController", ["getParser", "render", "renderRaw"]);
/**
* Reset static :: $formDefinition on controllers
*/
$this->definitionReflection = $reflection = (new \ReflectionObject($this->controller))->getProperty('formDefinition');
$reflection->setAccessible(true);
$this->formDefinition = $reflection->getValue();
$reflection->setValue(null);
/**
* Add the test type to the factory and
* the form to the container
*/
$factory = new FormFactoryBuilder();
$factory->addExtension(new CoreExtension());
$factory->addType(new TestType());
/**
* Construct the container
*/
$container = new Container();
$container->set("thelia.form_factory_builder", $factory);
$container->set("thelia.translator", new Translator($container));
$container->setParameter("thelia.parser.forms", array("test_form" => "Thelia\\Tests\\Resources\\Form\\TestForm"));
$request = new Request();
$request->setSession(new Session(new MockArraySessionStorage()));
$container->set("request", $request);
$container->set("thelia.forms.validator_builder", new ValidatorBuilder());
$container->set("event_dispatcher", new EventDispatcher());
$this->controller->setContainer($container);
}
示例2: __construct
public function __construct(Request $request)
{
if ($request->getSession() != null) {
$this->locale = $request->getSession()->getLang()->getLocale();
} else {
$this->locale = Lang::getDefaultLanguage()->getLocale();
}
}
示例3: getGetResponseEvent
protected function getGetResponseEvent()
{
$request = new Request();
$request->setSession(new Session(new MockArraySessionStorage()));
/** @var HttpKernelInterface $kernelMock */
$kernelMock = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\HttpKernelInterface')->disableOriginalConstructor()->getMock();
return new GetResponseEvent($kernelMock, $request, HttpKernelInterface::MASTER_REQUEST);
}
示例4: init
protected function init()
{
$container = $this->getContainer();
$request = new Request();
$request->setSession(new Session(new MockArraySessionStorage()));
/** @var RequestStack $requestStack */
$requestStack = $container->get('request_stack');
$requestStack->push($request);
}
示例5: setUp
public function setUp()
{
$session = new Session(new MockArraySessionStorage());
$request = new Request();
$request->setSession($session);
$this->mailerFactory = $this->getMockBuilder("Thelia\\Mailer\\MailerFactory")->disableOriginalConstructor()->getMock();
$translator = new Translator(new Container());
$this->tokenProvider = new TokenProvider($request, $translator, 'test');
}
示例6: getContainer
public function getContainer()
{
$container = new ContainerBuilder();
$container->set("event_dispatcher", $this->getDispatcher());
$request = new Request();
$request->setSession($this->session);
$container->set("request", $request);
return $container;
}
示例7: getContainer
public function getContainer()
{
$container = new \Symfony\Component\DependencyInjection\ContainerBuilder();
$container->set("event_dispatcher", $this->getDispatcher());
$request = new Request();
$request->setSession($this->session);
$container->set("request", $request);
return $container;
}
示例8: setUp
public function setUp()
{
parent::setUp();
$session = new Session(new MockArraySessionStorage());
$request = new Request();
$request->setSession($session);
$this->requestStack = new RequestStack();
$this->requestStack->push($request);
}
示例9: append
/**
* A simple helper to insert an entry in the admin log
*
* @param $resource
* @param $action
* @param $message
* @param Request $request
* @param UserInterface $adminUser
* @param bool $withRequestContent
*/
public static function append($resource, $action, $message, Request $request, UserInterface $adminUser = null, $withRequestContent = true)
{
$log = new AdminLog();
$log->setAdminLogin($adminUser !== null ? $adminUser->getUsername() : '<no login>')->setAdminFirstname($adminUser !== null && $adminUser instanceof Admin ? $adminUser->getFirstname() : '<no first name>')->setAdminLastname($adminUser !== null && $adminUser instanceof Admin ? $adminUser->getLastname() : '<no last name>')->setResource($resource)->setAction($action)->setMessage($message)->setRequest($request->toString($withRequestContent));
try {
$log->save();
} catch (\Exception $ex) {
Tlog::getInstance()->err("Failed to insert new entry in AdminLog: {ex}", array('ex' => $ex));
}
}
示例10: getContainer
public function getContainer()
{
$container = new \Symfony\Component\DependencyInjection\ContainerBuilder();
$dispatcher = $this->getMock("Symfony\\Component\\EventDispatcher\\EventDispatcherInterface");
$container->set("event_dispatcher", $dispatcher);
$fileManager = new FileManager(["document.product" => "Thelia\\Model\\ProductDocument", "image.product" => "Thelia\\Model\\ProductImage", "document.category" => "Thelia\\Model\\CategoryDocument", "image.category" => "Thelia\\Model\\CategoryImage", "document.content" => "Thelia\\Model\\ContentDocument", "image.content" => "Thelia\\Model\\ContentImage", "document.folder" => "Thelia\\Model\\FolderDocument", "image.folder" => "Thelia\\Model\\FolderImage", "document.brand" => "Thelia\\Model\\BrandDocument", "image.brand" => "Thelia\\Model\\BrandImage"]);
$container->set("thelia.file_manager", $this->getFileManager());
$request = new Request();
$request->setSession($this->session);
$container->set("request", $request);
return $container;
}
示例11: getContainer
public function getContainer()
{
$container = new \Symfony\Component\DependencyInjection\ContainerBuilder();
$container->set("thelia.translator", new Translator(new Container()));
$dispatcher = $this->getMock("Symfony\\Component\\EventDispatcher\\EventDispatcherInterface");
$container->set("event_dispatcher", $dispatcher);
$request = new Request();
$request->setSession($this->getSession());
$container->set("request", $request);
$container->set("thelia.securitycontext", new SecurityContext($request));
$this->buildContainer($container);
return $container;
}
示例12: notifyAction
/**
* @param Request $request
* @param $orderId
* @return Response
* @throws \Exception
*/
public function notifyAction(Request $request, $orderId)
{
$token = $request->get('token');
/** @var PaylineManager $payline */
$payline = $this->getContainer()->get('payline.manager');
if ($payline->getWebPaymentDetails($token)) {
$this->confirmPayment($orderId);
$this->cleanExpiredLog();
return new Response();
}
$this->cancelPayment($orderId);
$this->cleanExpiredLog();
return new Response();
}
示例13: handle
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
if (!$request instanceof \Thelia\Core\HttpFoundation\Request) {
$request = TheliaRequest::create($request->getUri(), $request->getMethod(), $request->getMethod() == 'GET' ? $request->query->all() : $request->request->all(), $request->cookies->all(), $request->files->all(), $request->server->all(), $request->getContent());
}
return parent::handle($request, $type, $catch);
}
示例14: createSubRequest
/**
* @param string $uri
* @param Request $request
* @return Request
*/
protected function createSubRequest($uri, Request $request)
{
$cookies = $request->cookies->all();
$server = $request->server->all();
// Override the arguments to emulate a sub-request.
// Sub-request object will point to localhost as client ip and real client ip
// will be included into trusted header for client ip
try {
if ($trustedHeaderName = Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) {
$currentXForwardedFor = $request->headers->get($trustedHeaderName, '');
$server['HTTP_' . $trustedHeaderName] = ($currentXForwardedFor ? $currentXForwardedFor . ', ' : '') . $request->getClientIp();
}
} catch (\InvalidArgumentException $e) {
// Do nothing
}
$server['REMOTE_ADDR'] = '127.0.0.1';
$subRequest = TheliaRequest::create($uri, 'get', array(), $cookies, array(), $server);
if ($request->headers->has('Surrogate-Capability')) {
$subRequest->headers->set('Surrogate-Capability', $request->headers->get('Surrogate-Capability'));
}
if ($session = $request->getSession()) {
$subRequest->setSession($session);
}
return $subRequest;
}
示例15: checkApiAccess
private function checkApiAccess(Request $request)
{
$key = $request->headers->get('authorization');
if (null !== $key) {
$key = substr($key, 6);
}
$apiAccount = ApiQuery::create()->findOneByApiKey($key);
if (null === $apiAccount) {
throw new UnauthorizedHttpException('Token');
}
$secureKey = pack('H*', $apiAccount->getSecureKey());
$sign = hash_hmac('sha1', $request->getContent(), $secureKey);
if ($sign != $request->query->get('sign')) {
throw new PreconditionFailedHttpException('wrong body request signature');
}
return $apiAccount;
}