本文整理汇总了PHP中Sylius\Bundle\ResourceBundle\Controller\RequestConfiguration类的典型用法代码示例。如果您正苦于以下问题:PHP RequestConfiguration类的具体用法?PHP RequestConfiguration怎么用?PHP RequestConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RequestConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function it_creates_the_object_if_form_is_a_class_name(RequestConfiguration $requestConfiguration, ResourceInterface $resource, FormFactoryInterface $formFactory, FormInterface $form)
{
$requestConfiguration->isHtmlRequest()->willReturn(true);
$requestConfiguration->getFormType()->willReturn(TextType::class);
$formFactory->create(Argument::type(TextType::class), $resource)->willReturn($form);
$this->create($requestConfiguration, $resource)->shouldReturn($form);
}
示例2: 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);
}
示例3:
function it_uses_a_custom_method_if_configured(RequestConfiguration $requestConfiguration, RepositoryInterface $repository, ResourceInterface $resource)
{
$requestConfiguration->getRepositoryMethod()->willReturn('findAll');
$requestConfiguration->getRepositoryArguments()->willReturn(array('foo'));
$repository->findAll('foo')->willReturn($resource);
$this->get($requestConfiguration, $repository)->shouldReturn($resource);
}
示例4:
function it_calls_proper_factory_methods_based_on_configuration(RequestConfiguration $requestConfiguration, FactoryInterface $factory)
{
$requestConfiguration->getFactoryMethod()->willReturn('createNew');
$requestConfiguration->getFactoryArguments()->willReturn(['00032']);
$factory->createNew('00032')->willReturn(['foo', 'bar']);
$this->create($requestConfiguration, $factory)->shouldReturn(['foo', 'bar']);
}
示例5: redirect
/**
* {@inheritdoc}
*/
public function redirect(RequestConfiguration $configuration, $url, $status = 302)
{
if ($configuration->isHeaderRedirection()) {
return new Response('', 200, ['X-SYLIUS-LOCATION' => $url . $configuration->getRedirectHash()]);
}
return new RedirectResponse($url . $configuration->getRedirectHash(), $status);
}
示例6: apply
/**
* {@inheritdoc}
*/
public function apply(RequestConfiguration $configuration, ResourceInterface $resource)
{
if (!$configuration->hasStateMachine()) {
throw new \InvalidArgumentException('State machine must be configured to apply transition, check your routing.');
}
$this->stateMachineFactory->get($resource, $configuration->getStateMachineGraph())->apply($configuration->getStateMachineTransition());
}
示例7: redirectToCartSummary
/**
* @param RequestConfiguration $configuration
*
* @return RedirectResponse
*/
protected function redirectToCartSummary(RequestConfiguration $configuration)
{
if (null === $configuration->getParameters()->get('redirect')) {
return $this->redirectHandler->redirectToRoute($configuration, $this->getCartSummaryRoute());
}
return $this->redirectHandler->redirectToRoute($configuration, $configuration->getParameters()->get('redirect'));
}
示例8: isGranted
/**
* @param RequestConfiguration $requestConfiguration
* @param string $permission
*
* @return bool
*/
public function isGranted(RequestConfiguration $requestConfiguration, $permission)
{
if (!$requestConfiguration->hasPermission()) {
return true;
}
return $this->rbacAuthorizationChecker->isGranted($permission);
}
示例9: create
/**
* {@inheritdoc}
*/
public function create(RequestConfiguration $requestConfiguration, FactoryInterface $factory)
{
if (null === ($method = $requestConfiguration->getFactoryMethod())) {
return $factory->createNew();
}
$arguments = array_values($requestConfiguration->getFactoryArguments());
return $factory->{$method}(...$arguments);
}
示例10: 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);
}
示例11: 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]);
}
示例12:
function it_creates_form_without_root_name_and_disables_csrf_protection_for_non_html_requests(RequestConfiguration $requestConfiguration, ResourceInterface $resource, FormFactoryInterface $formFactory, FormInterface $form)
{
$requestConfiguration->isHtmlRequest()->willReturn(false);
$requestConfiguration->getFormType()->willReturn('sylius_product_api');
$requestConfiguration->getFormOptions()->willReturn([]);
$formFactory->createNamed('', 'sylius_product_api', $resource, ['csrf_protection' => false])->willReturn($form);
$this->create($requestConfiguration, $resource)->shouldReturn($form);
}
示例13: dispatchPostEvent
/**
* {@inheritdoc}
*/
public function dispatchPostEvent($eventName, RequestConfiguration $requestConfiguration, ResourceInterface $resource)
{
$eventName = $requestConfiguration->getEvent() ?: $eventName;
$metadata = $requestConfiguration->getMetadata();
$event = $this->getEvent($resource);
$this->eventDispatcher->dispatch(sprintf('%s.%s.post_%s', $metadata->getApplicationName(), $metadata->getName(), $eventName), $event);
return $event;
}
示例14:
function it_applies_configured_state_machine_transition(RequestConfiguration $requestConfiguration, ResourceInterface $resource, FactoryInterface $stateMachineFactory, StateMachineInterface $stateMachine)
{
$requestConfiguration->hasStateMachine()->willReturn(true);
$requestConfiguration->getStateMachineGraph()->willReturn('sylius_product_review_state');
$requestConfiguration->getStateMachineTransition()->willReturn('reject');
$stateMachineFactory->get($resource, 'sylius_product_review_state')->willReturn($stateMachine);
$stateMachine->apply('reject')->shouldBeCalled();
$this->apply($requestConfiguration, $resource);
}
示例15: create
/**
* {@inheritdoc}
*/
public function create(RequestConfiguration $requestConfiguration, ResourceInterface $resource)
{
$formType = $requestConfiguration->getFormType();
$formOptions = $requestConfiguration->getFormOptions();
if ($requestConfiguration->isHtmlRequest()) {
return $this->formFactory->create($formType, $resource, $formOptions);
}
return $this->formFactory->createNamed('', $formType, $resource, array_merge($formOptions, ['csrf_protection' => false]));
}