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


PHP RequestConfiguration::isHtmlRequest方法代码示例

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


在下文中一共展示了RequestConfiguration::isHtmlRequest方法的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);
 }
开发者ID:Mangetsu,项目名称:Sylius,代码行数:7,代码来源:ResourceFormFactorySpec.php

示例2:

 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);
 }
开发者ID:sylius,项目名称:sylius,代码行数:8,代码来源:ResourceFormFactorySpec.php

示例3: 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]));
 }
开发者ID:sylius,项目名称:sylius,代码行数:12,代码来源:ResourceFormFactory.php

示例4: create

 /**
  * {@inheritdoc}
  */
 public function create(RequestConfiguration $requestConfiguration, ResourceInterface $resource)
 {
     $formType = $requestConfiguration->getFormType();
     if (false !== strpos($formType, '\\')) {
         $formType = new $formType();
     }
     if ($requestConfiguration->isHtmlRequest()) {
         return $this->formFactory->create($formType, $resource);
     }
     return $this->formFactory->createNamed('', $formType, $resource, ['csrf_protection' => false]);
 }
开发者ID:Mangetsu,项目名称:Sylius,代码行数:14,代码来源:ResourceFormFactory.php

示例5: handle

 /**
  * {@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);
 }
开发者ID:loic425,项目名称:Sylius,代码行数:14,代码来源:ViewHandler.php

示例6:

 function it_creates_paginator_by_default(RequestConfiguration $requestConfiguration, RepositoryInterface $repository, Pagerfanta $paginator)
 {
     $requestConfiguration->isHtmlRequest()->willReturn(true);
     $requestConfiguration->getRepositoryMethod()->willReturn(null);
     $requestConfiguration->isPaginated()->willReturn(true);
     $requestConfiguration->getPaginationMaxPerPage()->willReturn(5);
     $requestConfiguration->isLimited()->willReturn(false);
     $requestConfiguration->getCriteria()->willReturn([]);
     $requestConfiguration->getSorting()->willReturn([]);
     $repository->createPaginator([], [])->willReturn($paginator);
     $this->getResources($requestConfiguration, $repository)->shouldReturn($paginator);
 }
开发者ID:TheMadeleine,项目名称:Sylius,代码行数:12,代码来源:ResourcesResolverSpec.php

示例7: SerializationContext

 function it_sets_proper_values_for_non_html_requests(RequestConfiguration $requestConfiguration, RestViewHandler $restViewHandler, Response $response)
 {
     $requestConfiguration->isHtmlRequest()->willReturn(false);
     $view = View::create();
     $view->setSerializationContext(new SerializationContext());
     $requestConfiguration->getSerializationGroups()->willReturn(['Detailed']);
     $requestConfiguration->getSerializationVersion()->willReturn('2.0.0');
     $restViewHandler->setExclusionStrategyGroups(['Detailed'])->shouldBeCalled();
     $restViewHandler->setExclusionStrategyVersion('2.0.0')->shouldBeCalled();
     $restViewHandler->handle($view)->willReturn($response);
     $this->handle($requestConfiguration, $view)->shouldReturn($response);
 }
开发者ID:gabiudrescu,项目名称:Sylius,代码行数:12,代码来源:ViewHandlerSpec.php

示例8:

 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);
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:14,代码来源:ResourcesResolverSpec.php

示例9:

 function it_uses_default_translation_if_message_is_not_translated(SessionInterface $session, FlashBagInterface $flashBag, TranslatorInterface $translator, MetadataInterface $metadata, RequestConfiguration $requestConfiguration, ResourceInterface $resource)
 {
     $metadata->getApplicationName()->willReturn('sylius');
     $metadata->getName()->willReturn('product');
     $metadata->getHumanizedName()->willReturn('product');
     $requestConfiguration->getMetadata()->willReturn($metadata);
     $requestConfiguration->isHtmlRequest()->willReturn(true);
     $session->getBag('flashes')->willReturn($flashBag);
     $requestConfiguration->getFlashMessage(ResourceActions::CREATE)->willReturn('sylius.product.create');
     $translator->trans('sylius.product.create', ['%resource%' => 'Product'], 'flashes')->willReturn('sylius.product.create');
     $translator->trans('sylius.resource.create', ['%resource%' => 'Product'], 'flashes')->willReturn('Product has been successfully created.');
     $flashBag->add('success', 'Product has been successfully created.')->shouldBeCalled();
     $this->addSuccessFlash($requestConfiguration, ResourceActions::CREATE, $resource);
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:14,代码来源:FlashHelperSpec.php

示例10:

 function it_creates_a_paginated_representation_for_pagerfanta_for_non_html_requests(ResourcesResolverInterface $resourcesResolver, RequestConfiguration $requestConfiguration, RepositoryInterface $repository, Pagerfanta $paginator, Request $request, ParameterBag $queryParameters, ParameterBag $requestAttributes, PagerfantaFactory $pagerfantaRepresentationFactory, PaginatedRepresentation $paginatedRepresentation)
 {
     $requestConfiguration->isHtmlRequest()->willReturn(false);
     $requestConfiguration->getPaginationMaxPerPage()->willReturn(8);
     $resourcesResolver->getResources($requestConfiguration, $repository)->willReturn($paginator);
     $requestConfiguration->getRequest()->willReturn($request);
     $request->query = $queryParameters;
     $queryParameters->get('page', 1)->willReturn(6);
     $queryParameters->all()->willReturn(['foo' => 2, 'bar' => 15]);
     $request->attributes = $requestAttributes;
     $requestAttributes->get('_route')->willReturn('sylius_product_index');
     $requestAttributes->get('_route_params')->willReturn(['slug' => 'foo-bar']);
     $paginator->setMaxPerPage(8)->shouldBeCalled();
     $paginator->setCurrentPage(6)->shouldBeCalled();
     $pagerfantaRepresentationFactory->createRepresentation($paginator, Argument::type(Route::class))->willReturn($paginatedRepresentation);
     $this->get($requestConfiguration, $repository)->shouldReturn($paginatedRepresentation);
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:17,代码来源:ResourcesCollectionProviderSpec.php

示例11: 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;
 }
开发者ID:Mangetsu,项目名称:Sylius,代码行数:25,代码来源:ResourcesCollectionProvider.php

示例12: 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);
 }
开发者ID:Spomky,项目名称:Sylius,代码行数:20,代码来源:ResourcesCollectionProviderSpec.php

示例13: handleChangePassword

 /**
  * @param Request $request
  * @param RequestConfiguration $configuration
  * @param UserInterface $user
  * @param string $newPassword
  *
  * @return RedirectResponse
  */
 protected function handleChangePassword(Request $request, RequestConfiguration $configuration, UserInterface $user, $newPassword)
 {
     $user->setPlainPassword($newPassword);
     $dispatcher = $this->container->get('event_dispatcher');
     $dispatcher->dispatch(UserEvents::PRE_PASSWORD_CHANGE, new GenericEvent($user));
     $this->manager->flush();
     $this->addFlash('success', 'sylius.user.password.change.success');
     $dispatcher->dispatch(UserEvents::POST_PASSWORD_CHANGE, new GenericEvent($user));
     if (!$configuration->isHtmlRequest()) {
         return $this->viewHandler->handle($configuration, View::create(null, Response::HTTP_NO_CONTENT));
     }
     $redirectRouteName = $request->attributes->get('_sylius[redirect]', 'sylius_account_profile_show', true);
     return new RedirectResponse($this->container->get('router')->generate($redirectRouteName));
 }
开发者ID:gabiudrescu,项目名称:Sylius,代码行数:22,代码来源:UserController.php

示例14: handleChangePassword

 /**
  * @param Request $request
  * @param RequestConfiguration $configuration
  * @param UserInterface $user
  * @param string $newPassword
  *
  * @return Response
  */
 protected function handleChangePassword(Request $request, RequestConfiguration $configuration, UserInterface $user, $newPassword)
 {
     $user->setPlainPassword($newPassword);
     $dispatcher = $this->container->get('event_dispatcher');
     $dispatcher->dispatch(UserEvents::PRE_PASSWORD_CHANGE, new GenericEvent($user));
     $this->manager->flush();
     $this->addFlash('success', 'sylius.user.change_password');
     $dispatcher->dispatch(UserEvents::POST_PASSWORD_CHANGE, new GenericEvent($user));
     if (!$configuration->isHtmlRequest()) {
         return $this->viewHandler->handle($configuration, View::create(null, Response::HTTP_NO_CONTENT));
     }
     $redirectRouteName = $this->getSyliusAttribute($request, 'redirect', null);
     Assert::notNull($redirectRouteName, 'Redirect is not configured.');
     return new RedirectResponse($this->container->get('router')->generate($redirectRouteName));
 }
开发者ID:sylius,项目名称:sylius,代码行数:23,代码来源:UserController.php

示例15: handleChangePassword

 /**
  * @param UserInterface $user
  * @param string        $newPassword
  *
  * @return RedirectResponse
  */
 protected function handleChangePassword(RequestConfiguration $configuration, UserInterface $user, $newPassword)
 {
     $user->setPlainPassword($newPassword);
     $dispatcher = $this->container->get('event_dispatcher');
     $dispatcher->dispatch(UserEvents::PRE_PASSWORD_CHANGE, new GenericEvent($user));
     $this->manager->flush();
     $this->addFlash('success', 'sylius.user.password.change.success');
     $dispatcher->dispatch(UserEvents::POST_PASSWORD_CHANGE, new GenericEvent($user));
     if (!$configuration->isHtmlRequest()) {
         return $this->viewHandler->handle(View::create($user, 204));
     }
     return new RedirectResponse($this->container->get('router')->generate('sylius_account_profile_show'));
 }
开发者ID:Spomky,项目名称:Sylius,代码行数:19,代码来源:UserController.php


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