本文整理匯總了PHP中Sylius\Bundle\ResourceBundle\Controller\RequestConfiguration::getRequest方法的典型用法代碼示例。如果您正苦於以下問題:PHP RequestConfiguration::getRequest方法的具體用法?PHP RequestConfiguration::getRequest怎麽用?PHP RequestConfiguration::getRequest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Sylius\Bundle\ResourceBundle\Controller\RequestConfiguration
的用法示例。
在下文中一共展示了RequestConfiguration::getRequest方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: create
/**
* {@inheritdoc}
*/
public function create(Grid $grid, Parameters $parameters, MetadataInterface $metadata, RequestConfiguration $requestConfiguration)
{
$driverConfiguration = $grid->getDriverConfiguration();
$request = $requestConfiguration->getRequest();
$grid->setDriverConfiguration($this->parametersParser->parseRequestValues($driverConfiguration, $request));
return new ResourceGridView($this->dataProvider->getData($grid, $parameters), $grid, $parameters, $metadata, $requestConfiguration);
}
示例2: redirectToCartSummary
protected function redirectToCartSummary(RequestConfiguration $configuration)
{
$format = $configuration->getRequest()->getRequestFormat('html');
if (null === $configuration->getParameters()->get('redirect')) {
return $this->getRedirectHandler()->redirectToRoute($configuration, $this->getCartSummaryRoute(), ['_format' => $format]);
}
return $this->getRedirectHandler()->redirectToRoute($configuration, $this->getCartSummaryRoute(), ['_format' => $format]);
}
示例3: redirectAfterAdd
/**
* Redirect to specific URL or to cart.
*
* @param Request $request
*
* @return RedirectResponse
*/
private function redirectAfterAdd(RequestConfiguration $configuration)
{
$request = $configuration->getRequest();
if ($request->query->has('_redirect_to')) {
return $this->redirectHandler->redirect($configuration, $request->query->get('_redirect_to'));
}
return $this->redirectToCartSummary($configuration);
}
示例4:
function it_redirect_to_referer(RequestConfiguration $configuration, Request $request, ParameterBag $bag)
{
$request->headers = $bag;
$bag->get('referer')->willReturn('http://myurl.com');
$configuration->getRequest()->willReturn($request);
$configuration->getRedirectHash()->willReturn(null);
$configuration->getRedirectReferer()->willReturn('http://myurl.com');
$configuration->isHeaderRedirection()->willReturn(false);
$this->redirectToReferer($configuration)->shouldHaveType(RedirectResponse::class);
}
示例5: ResourceGridView
function it_uses_data_provider_to_create_a_view_with_data_and_definition(DataProviderInterface $dataProvider, ParametersParserInterface $parametersParser, Grid $grid, Parameters $parameters, MetadataInterface $resourceMetadata, Request $request, RequestConfiguration $requestConfiguration)
{
$expectedResourceGridView = new ResourceGridView(['foo', 'bar'], $grid->getWrappedObject(), $parameters->getWrappedObject(), $resourceMetadata->getWrappedObject(), $requestConfiguration->getWrappedObject());
$requestConfiguration->getRequest()->willReturn($request);
$parametersParser->parseRequestValues(['repository' => ['method' => 'createByCustomerQueryBuilder', 'arguments' => ['$customerId']]], $request)->willReturn(['repository' => ['method' => 'createByCustomerQueryBuilder', 'arguments' => [5]]]);
$grid->getDriverConfiguration()->willReturn(['repository' => ['method' => 'createByCustomerQueryBuilder', 'arguments' => ['$customerId']]]);
$grid->setDriverConfiguration(['repository' => ['method' => 'createByCustomerQueryBuilder', 'arguments' => [5]]])->shouldBeCalled();
$dataProvider->getData($grid, $parameters)->willReturn(['foo', 'bar']);
$this->create($grid, $parameters, $resourceMetadata, $requestConfiguration)->shouldBeSameResourceGridViewAs($expectedResourceGridView);
}
示例6:
function it_can_find_specific_resource_with_slug_by_default(RequestConfiguration $requestConfiguration, Request $request, ParameterBag $requestAttributes, RepositoryInterface $repository, ResourceInterface $resource)
{
$requestConfiguration->getRepositoryMethod()->willReturn(null);
$requestConfiguration->getRequest()->willReturn($request);
$request->attributes = $requestAttributes;
$requestAttributes->has('id')->willReturn(false);
$requestAttributes->has('slug')->willReturn(true);
$requestAttributes->get('slug')->willReturn('the-most-awesome-hat');
$repository->findOneBy(array('slug' => 'the-most-awesome-hat'))->willReturn($resource);
$this->get($requestConfiguration, $repository)->shouldReturn($resource);
}
示例7: findOr404
public function findOr404(RequestConfiguration $configuration)
{
$request = $configuration->getRequest();
if ($request->attributes->has('_page')) {
$page = $request->attributes->get('_page');
if ($page->getId() !== null) {
return $page;
}
}
return parent::findOr404($configuration);
}
示例8: get
/**
* {@inheritdoc}
*/
public function get(RequestConfiguration $requestConfiguration, RepositoryInterface $repository)
{
if ($requestConfiguration->hasPermission() && $this->requireOwnerCheck($vars = $requestConfiguration->getVars())) {
$owner = $this->currentIdentityProvider->getIdentity();
$ownerField = is_bool($vars['acl_owner']) ? ResourceOwnerFilter::FIELD : $vars['acl_owner'];
// using in grid param
$requestConfiguration->getRequest()->query->set(ResourceOwnerFilter::TYPE, $owner);
$criteria = $requestConfiguration->getCriteria();
$criteria[$ownerField] = $owner;
$requestConfiguration->getParameters()->set('criteria', $criteria);
}
return $this->decoratedResolver->get($requestConfiguration, $repository);
}
示例9:
function it_returns_grid_data_for_non_html_requests(RequestConfiguration $requestConfiguration, RepositoryInterface $repository, Grid $gridDefinition, GridProviderInterface $gridProvider, ResourceGridViewFactoryInterface $gridViewFactory, ResourceGridView $gridView, Pagerfanta $paginator, MetadataInterface $metadata, Request $request, ParameterBag $queryParameters)
{
$requestConfiguration->hasGrid()->willReturn(true);
$requestConfiguration->getGrid()->willReturn('sylius_admin_tax_category');
$requestConfiguration->getMetadata()->willReturn($metadata);
$requestConfiguration->isHtmlRequest()->willReturn(false);
$requestConfiguration->getRequest()->willReturn($request);
$request->query = $queryParameters;
$queryParameters->all()->willReturn(['foo' => 'bar']);
$gridProvider->get('sylius_admin_tax_category')->willReturn($gridDefinition);
$gridViewFactory->create($gridDefinition, Argument::type(Parameters::class), $metadata, $requestConfiguration)->willReturn($gridView);
$gridView->getData()->willReturn($paginator);
$this->getResources($requestConfiguration, $repository)->shouldReturn($paginator);
}
示例10: get
/**
* {@inheritdoc}
*/
public function get(RequestConfiguration $requestConfiguration, RepositoryInterface $repository)
{
if (null !== ($repositoryMethod = $requestConfiguration->getRepositoryMethod())) {
$callable = array($repository, $repositoryMethod);
return call_user_func_array($callable, $requestConfiguration->getRepositoryArguments());
}
$criteria = array();
$request = $requestConfiguration->getRequest();
if ($request->attributes->has('id')) {
$criteria = array('id' => $request->attributes->get('id'));
}
if ($request->attributes->has('slug')) {
$criteria = array('slug' => $request->attributes->get('slug'));
}
return $repository->findOneBy($criteria);
}
示例11: get
/**
* {@inheritdoc}
*/
public function get(RequestConfiguration $requestConfiguration, RepositoryInterface $repository)
{
$repositoryMethod = $requestConfiguration->getRepositoryMethod();
if (null !== $repositoryMethod) {
$arguments = array_values($requestConfiguration->getRepositoryArguments());
return $repository->{$repositoryMethod}(...$arguments);
}
$criteria = [];
$request = $requestConfiguration->getRequest();
if ($request->attributes->has('id')) {
return $repository->find($request->attributes->get('id'));
}
if ($request->attributes->has('slug')) {
$criteria = ['slug' => $request->attributes->get('slug')];
}
$criteria = array_merge($criteria, $requestConfiguration->getCriteria());
return $repository->findOneBy($criteria);
}
示例12: get
/**
* {@inheritdoc}
*/
public function get(RequestConfiguration $requestConfiguration, RepositoryInterface $repository)
{
if (null !== ($repositoryMethod = $requestConfiguration->getRepositoryMethod())) {
$callable = [$repository, $repositoryMethod];
return call_user_func_array($callable, $requestConfiguration->getRepositoryArguments());
}
if (!$requestConfiguration->isPaginated() && !$requestConfiguration->isLimited()) {
return $repository->findAll();
}
if (!$requestConfiguration->isPaginated()) {
return $repository->findBy($requestConfiguration->getCriteria(), $requestConfiguration->getSorting(), $requestConfiguration->getLimit());
}
$request = $requestConfiguration->getRequest();
/** @var Pagerfanta $paginator */
$paginator = $repository->createPaginator($requestConfiguration->getCriteria(), $requestConfiguration->getSorting());
$paginator->setCurrentPage($request->query->get('page', 1));
if (!$requestConfiguration->isHtmlRequest()) {
$route = new Route($request->attributes->get('_route'), array_merge($request->attributes->get('_route_params'), $request->query->all()));
return $this->pagerfantaRepresentationFactory->createRepresentation($paginator, $route);
}
return $paginator;
}
示例13: array
function it_creates_a_pagniated_respresentation_for_pagerfanta_for_non_html_requests(RequestConfiguration $requestConfiguration, RepositoryInterface $repository, Pagerfanta $paginator, Request $request, ParameterBag $queryParameters, ParameterBag $requestAttributes, PagerfantaFactory $pagerfantaRepresentationFactory, PaginatedRepresentation $paginatedRepresentation)
{
$requestConfiguration->isHtmlRequest()->willReturn(false);
$requestConfiguration->getRepositoryMethod()->willReturn(null);
$requestConfiguration->isPaginated()->willReturn(true);
$requestConfiguration->isLimited()->willReturn(false);
$requestConfiguration->getCriteria()->willReturn(array());
$requestConfiguration->getSorting()->willReturn(array());
$repository->createPaginator(array(), array())->willReturn($paginator);
$requestConfiguration->getRequest()->willReturn($request);
$request->query = $queryParameters;
$queryParameters->get('page', 1)->willReturn(6);
$queryParameters->all()->willReturn(array('foo' => 2, 'bar' => 15));
$request->attributes = $requestAttributes;
$requestAttributes->get('_route')->willReturn('sylius_product_index');
$requestAttributes->get('_route_params')->willReturn(array('slug' => 'foo-bar'));
$paginator->setCurrentPage(6)->shouldBeCalled();
$pagerfantaRepresentationFactory->createRepresentation($paginator, Argument::type(Route::class))->willReturn($paginatedRepresentation);
$this->get($requestConfiguration, $repository)->shouldReturn($paginatedRepresentation);
}
示例14:
function it_can_find_specific_resource_with_merged_custom_criteria_overwriting_the_attributes(RequestConfiguration $requestConfiguration, Request $request, ParameterBag $requestAttributes, RepositoryInterface $repository, ResourceInterface $resource)
{
$requestConfiguration->getCriteria()->willReturn(['id' => 5]);
$requestConfiguration->getRepositoryMethod()->willReturn(null);
$requestConfiguration->getRequest()->willReturn($request);
$request->attributes = $requestAttributes;
$requestAttributes->has('id')->willReturn(false);
$requestAttributes->has('slug')->willReturn(false);
$repository->findOneBy(['id' => 5])->willReturn($resource);
$this->get($requestConfiguration, $repository)->shouldReturn($resource);
}
示例15: findOr404
/**
* @param RequestConfiguration $configuration
*
* @return ProductInterface|null
*/
public function findOr404(RequestConfiguration $configuration)
{
$request = $configuration->getRequest();
if ($request->attributes->has('_sylius_entity')) {
return $request->attributes->get('_sylius_entity');
}
return parent::findOr404($configuration);
}