當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。