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


PHP Configuration\ParamConverter类代码示例

本文整理汇总了PHP中Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter的典型用法代码示例。如果您正苦于以下问题:PHP ParamConverter类的具体用法?PHP ParamConverter怎么用?PHP ParamConverter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ParamConverter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: supports

 /**
  * Checks if the object is supported.
  *
  * @param ParamConverter $configuration Should be an instance of ParamConverter
  *
  * @return bool True if the object is supported, else false
  */
 public function supports(ParamConverter $configuration)
 {
     if (null === $configuration->getConverter()) {
         return false;
     }
     return 'drupal.router_item' === $configuration->getConverter();
 }
开发者ID:bangpound,项目名称:drupal-bridge,代码行数:14,代码来源:RouterItemConverter.php

示例2: execute

 /**
  * execute
  *
  * @param Request              $request
  * @param SensioParamConverter $configuration
  *
  * @return bool|mixed
  */
 public function execute(Request $request, SensioParamConverter $configuration)
 {
     $id = $request->attributes->get('id');
     $locale = $request->attributes->get('locale');
     $url = $request->attributes->get('url');
     $name = $configuration->getName();
     $options = $configuration->getOptions();
     $resolvedClass = $configuration->getClass();
     $method = $request->getMethod();
     $rawPayload = $request->getContent();
     switch (true) {
         case 'GET' === $method:
             $convertedValue = $this->loadEntity($resolvedClass, $id, $locale, $url);
             break;
         case 'DELETE' === $method:
             $convertedValue = $this->loadEntity($resolvedClass, $id, $locale, $url);
             break;
         case 'PUT' === $method:
             $payload = array_merge(array('id' => $id), json_decode($rawPayload, true));
             $convertedValue = $this->updateEntity($resolvedClass, json_encode($payload));
             break;
         case 'POST' === $method:
             $convertedValue = $this->updateEntity($resolvedClass, $rawPayload);
             break;
     }
     return $convertedValue;
 }
开发者ID:alexjobs,项目名称:Aisel,代码行数:35,代码来源:ParamConverter.php

示例3: checkFailureOnValidationError

 /**
  * @param ParamConverter $configuration
  * @return bool
  */
 protected function checkFailureOnValidationError(ParamConverter $configuration)
 {
     if (isset($configuration->getOptions()['fail_on_validation_error'])) {
         return $configuration->getOptions()['fail_on_validation_error'];
     }
     return $this->failOnValidationError;
 }
开发者ID:ibrows,项目名称:rest-bundle,代码行数:11,代码来源:RequestBodyParamConverter.php

示例4: it_should_support

 public function it_should_support(ParamConverter $configuration)
 {
     $configuration->getClass()->willReturn(JsonApi::class);
     $this->supports($configuration)->shouldReturn(true);
     $configuration->getClass()->willReturn(stdClass::class);
     $this->supports($configuration)->shouldReturn(false);
 }
开发者ID:qpautrat,项目名称:woohoolabs-yin-bundle,代码行数:7,代码来源:JsonApiParamConverterSpec.php

示例5: supports

 function supports(ParamConverter $configuration)
 {
     if ('json' !== $configuration->getNAme()) {
         return false;
     }
     return true;
 }
开发者ID:sungvadan,项目名称:Symfony,代码行数:7,代码来源:JsonParamConverter.php

示例6: supports

 /**
  * {@inheritdoc}
  */
 public function supports(ParamConverter $configuration)
 {
     if (null === $configuration->getClass()) {
         return false;
     }
     return isset(self::$supportedTypes[$configuration->getClass()]);
 }
开发者ID:RuntyCybin,项目名称:csymfony,代码行数:10,代码来源:PsrServerRequestParamConverter.php

示例7: supports

 /**
  * {@inheritdoc}
  */
 public function supports(ParamConverter $configuration)
 {
     if (!$configuration->getClass()) {
         return false;
     }
     return true;
 }
开发者ID:jcart,项目名称:framework-extra-bundle,代码行数:10,代码来源:EncodedParamConverter.php

示例8: supports

 /**
  * Checks if the object is supported.
  *
  * @param ParamConverter $configuration Should be an instance of ParamConverter
  *
  * @return bool True if the object is supported, else false
  */
 public function supports(ParamConverter $configuration)
 {
     if (null === $configuration->getClass()) {
         return false;
     }
     return $configuration->getClass() === Category::class;
 }
开发者ID:karion,项目名称:mydrinks,代码行数:14,代码来源:CategoryConverter.php

示例9: supports

 /**
  * {@inheritdoc}
  */
 public function supports(ParamConverter $configuration)
 {
     if (!($class = $configuration->getClass())) {
         return false;
     }
     return 'DTO' === strtoupper(substr($class, -3));
 }
开发者ID:thesoftwarefactoryuk,项目名称:SenNetwork,代码行数:10,代码来源:DataTransferObjectParamConverter.php

示例10: onKernelController

 /**
  * Modifies the ParamConverterManager instance.
  *
  * @param FilterControllerEvent $event A FilterControllerEvent instance
  */
 public function onKernelController(FilterControllerEvent $event)
 {
     $controller = $event->getController();
     $request = $event->getRequest();
     $configurations = array();
     if ($configuration = $request->attributes->get('_converters')) {
         foreach (is_array($configuration) ? $configuration : array($configuration) as $configuration) {
             $configurations[$configuration->getName()] = $configuration;
         }
     }
     if (is_array($controller)) {
         $r = new \ReflectionMethod($controller[0], $controller[1]);
     } else {
         $r = new \ReflectionFunction($controller);
     }
     // automatically apply conversion for non-configured objects
     foreach ($r->getParameters() as $param) {
         if (!$param->getClass() || $param->getClass()->isInstance($request)) {
             continue;
         }
         $name = $param->getName();
         if (!isset($configurations[$name])) {
             $configuration = new ParamConverter(array());
             $configuration->setName($name);
             $configuration->setClass($param->getClass()->getName());
             $configurations[$name] = $configuration;
         } elseif (null === $configurations[$name]->getClass()) {
             $configurations[$name]->setClass($param->getClass()->getName());
         }
         $configurations[$name]->setIsOptional($param->isOptional());
     }
     $this->manager->apply($request, $configurations);
 }
开发者ID:joan16v,项目名称:symfony2_test,代码行数:38,代码来源:ParamConverterListener.php

示例11: supports

 /**
  * {@inheritdoc}
  */
 public function supports(ParamConverter $configuration)
 {
     if (null === $configuration->getClass()) {
         return false;
     }
     return "DateTime" === $configuration->getClass();
 }
开发者ID:neteasy-work,项目名称:hkgbf_crm,代码行数:10,代码来源:DateTimeParamConverter.php

示例12: onCoreController

 /**
  * Modifies the ParamConverterManager instance.
  *
  * @param FilterControllerEvent $event A FilterControllerEvent instance
  */
 public function onCoreController(FilterControllerEvent $event)
 {
     $controller = $event->getController();
     $request = $event->getRequest();
     $configurations = array();
     if ($configuration = $request->attributes->get('_converters')) {
         $configurations = is_array($configuration) ? $configuration : array($configuration);
     }
     if (is_array($controller)) {
         $r = new \ReflectionMethod($controller[0], $controller[1]);
     } else {
         $r = new \ReflectionFunction($controller);
     }
     // automatically apply conversion for non-configured objects
     foreach ($r->getParameters() as $param) {
         if ($param->getClass() && !$request->attributes->get($param->getName())) {
             $configuration = new ParamConverter(array());
             $configuration->setName($param->getName());
             $configuration->setClass($param->getClass()->getName());
             $configuration->setIsOptional($param->isOptional());
             $configurations[] = $configuration;
         }
     }
     $this->manager->apply($request, $configurations);
 }
开发者ID:rfc1483,项目名称:symfony,代码行数:30,代码来源:ParamConverterListener.php

示例13: supports

 public function supports(ParamConverter $configuration)
 {
     if (null === $configuration->getClass()) {
         return false;
     }
     return in_array($configuration->getClass(), $this->supportedTypes);
 }
开发者ID:WellCommerce,项目名称:CoreBundle,代码行数:7,代码来源:AbstractEntityParamConverter.php

示例14: supports

 /**
  * @param ParamConverter $configuration
  * @return bool
  */
 public function supports(ParamConverter $configuration)
 {
     if (null === $configuration->getClass()) {
         return false;
     }
     return 'CiTron\\Project\\Entity\\Project' === $configuration->getClass();
 }
开发者ID:ci-tron,项目名称:ci-tron,代码行数:11,代码来源:ProjectParamConverter.php

示例15: execute

 /**
  * Stores the object in the request.
  *
  * @param Request        $request       The request
  * @param ParamConverter $configuration Contains the name, class and options of the object
  *
  * @return boolean True if the object has been successfully set, else false
  *
  * @throws UnsupportedMediaTypeHttpException
  * @throws BadRequestHttpException
  */
 protected function execute(Request $request, ParamConverter $configuration)
 {
     $options = (array) $configuration->getOptions();
     if (isset($options['deserializationContext']) && is_array($options['deserializationContext'])) {
         $context = array_merge($this->context, $options['deserializationContext']);
     } else {
         $context = $this->context;
     }
     if ($this->serializer instanceof SerializerInterface) {
         $context = $this->configureDeserializationContext($this->getDeserializationContext(), $context);
     }
     try {
         $object = $this->serializer->deserialize($request->getContent(), $configuration->getClass(), $request->getContentType(), $context);
     } catch (UnsupportedFormatException $e) {
         throw new UnsupportedMediaTypeHttpException($e->getMessage());
     } catch (JMSSerializerException $e) {
         throw new BadRequestHttpException($e->getMessage());
     } catch (SymfonySerializerException $e) {
         throw new BadRequestHttpException($e->getMessage());
     }
     $request->attributes->set($configuration->getName(), $object);
     if (null !== $this->validator) {
         $validatorOptions = $this->getValidatorOptions($options);
         $request->attributes->set($this->validationErrorsArgument, $this->validator->validate($object, $validatorOptions['groups'], $validatorOptions['traverse'], $validatorOptions['deep']));
     }
     return true;
 }
开发者ID:ygeneration666,项目名称:ma,代码行数:38,代码来源:AbstractRequestBodyParamConverter.php


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