php Sylius-Bundle-ResourceBundle-Controller-RequestConfiguration类(方法)实例源码

下面列出了php Sylius-Bundle-ResourceBundle-Controller-RequestConfiguration 类(方法)源码代码实例,从而了解它的用法。

作者:Mangets    项目:Syliu   
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);
 }

作者:ReissClothin    项目:Syliu   
/**
  * {@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);
 }

作者:Spomk    项目:Syliu   
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);
 }

作者:gabiudresc    项目:Syliu   
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']);
 }

作者:ReissClothin    项目:Syliu   
/**
  * {@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);
 }

作者:loic42    项目:Syliu   
/**
  * {@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());
 }

作者:okwinz    项目:Syliu   
/**
  * @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'));
 }

作者:okwinz    项目:Syliu   
/**
  * @param RequestConfiguration $requestConfiguration
  * @param string $permission
  *
  * @return bool
  */
 public function isGranted(RequestConfiguration $requestConfiguration, $permission)
 {
     if (!$requestConfiguration->hasPermission()) {
         return true;
     }
     return $this->rbacAuthorizationChecker->isGranted($permission);
 }

作者:loic42    项目:Syliu   
/**
  * {@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);
 }

作者:ahmadrabi    项目:Syliu   
/**
  * 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);
 }

作者:enhav    项目:enhav   
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]);
 }

作者:syliu    项目:syliu   
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);
 }

作者:loic42    项目:Syliu   
/**
  * {@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;
 }

作者:TheMadelein    项目:Syliu   
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);
 }

作者:syliu    项目:syliu   
/**
  * {@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]));
 }

作者:vikey8    项目:Syliu   
function it_uses_rbac_authorization_checker(RequestConfiguration $requestConfiguration, RbacAuthorizationCheckerInterface $rbacAuthorizationChecker)
 {
     $requestConfiguration->hasPermission()->willReturn(true);
     $requestConfiguration->getPermission('sylius.product.foo')->willReturn('sylius.product.foo');
     $rbacAuthorizationChecker->isGranted('sylius.product.foo')->willReturn(false);
     $this->isGranted($requestConfiguration, 'sylius.product.foo')->shouldReturn(false);
     $rbacAuthorizationChecker->isGranted('sylius.product.foo')->willReturn(true);
     $this->isGranted($requestConfiguration, 'sylius.product.foo')->shouldReturn(true);
 }

作者:ReissClothin    项目:Syliu   
/**
  * {@inheritdoc}
  */
 public function create(RequestConfiguration $requestConfiguration, FactoryInterface $factory)
 {
     if (null === ($method = $requestConfiguration->getFactoryMethod())) {
         return $factory->createNew();
     }
     $callable = [$factory, $method];
     $arguments = $requestConfiguration->getFactoryArguments();
     return call_user_func_array($callable, $arguments);
 }

作者:ReissClothin    项目:Syliu   
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);
 }

作者:ahmadrabi    项目:Syliu   
/**
  * {@inheritdoc}
  */
 public function addSuccessFlash(RequestConfiguration $requestConfiguration, $actionName, ResourceInterface $resource = null)
 {
     $metadata = $requestConfiguration->getMetadata();
     $flashMessage = $requestConfiguration->getFlashMessage($actionName);
     $translatedMessage = $this->translateMessage($flashMessage, $metadata);
     if ($flashMessage === $translatedMessage) {
         $translatedMessage = $this->translateMessage(sprintf('sylius.resource.%s', $actionName), $metadata);
     }
     $this->session->getBag('flashes')->add('success', $translatedMessage);
 }

作者:loic42    项目:Syliu   
/**
  * {@inheritdoc}
  */
 public function handle(RequestConfiguration $requestConfiguration, View $view)
 {
     if (!$requestConfiguration->isHtmlRequest()) {
         $this->restViewHandler->setExclusionStrategyGroups($requestConfiguration->getSerializationGroups());
         if ($version = $requestConfiguration->getSerializationVersion()) {
             $this->restViewHandler->setExclusionStrategyVersion($version);
         }
         $view->getSerializationContext()->enableMaxDepthChecks();
     }
     return $this->restViewHandler->handle($view);
 }


问题


面经


文章

微信
公众号

扫码关注公众号