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


PHP ParamConverter::getOptions方法代码示例

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


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

示例1: 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

示例2: getRequestAttributeName

 /**
  * @param Request        $request
  * @param ParamConverter $configuration
  * @return string
  */
 protected function getRequestAttributeName(Request $request, ParamConverter $configuration)
 {
     $param = $configuration->getName();
     if (array_key_exists('id', $configuration->getOptions())) {
         $param = $configuration->getOptions()['id'];
     }
     return $param;
 }
开发者ID:VincentChalnot,项目名称:SidusEAVModelBundle,代码行数:13,代码来源:AbstractBaseParamConverter.php

示例3: apply

 public function apply(Request $request, ParamConverter $configuration)
 {
     if ($request->isMethod('POST') && !empty($configuration->getOptions()['request_path'])) {
         $requestPath = $configuration->getOptions()['request_path'];
         $request->attributes->set($requestPath, $request->request->get($requestPath));
     } elseif ($request->isMethod('GET') && !empty($configuration->getOptions()['query_path'])) {
         $queryPath = $configuration->getOptions()['query_path'];
         $request->attributes->set($queryPath, $request->query->get($queryPath));
     }
     return parent::apply($request, $configuration);
 }
开发者ID:Briareos,项目名称:Undine,代码行数:11,代码来源:DoctrineParamConverter.php

示例4: it_supports_translatable_classes

 public function it_supports_translatable_classes(ParamConverter $paramConverter, TranslatableMetadata $translatableMetadata)
 {
     $paramConverter->getOptions()->willReturn(array());
     $paramConverter->getClass()->willReturn('TranslatableEntity');
     $translatableMetadata->hasTranslatableProperties()->willReturn(true);
     $this->supports($paramConverter)->shouldReturn(true);
 }
开发者ID:norzechowicz,项目名称:doctrine-extensions-bundle,代码行数:7,代码来源:TranslatableParamConverterSpec.php

示例5: 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

示例6: 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

示例7: apply

 /**
  * {@inheritdoc}
  */
 public function apply(Request $request, ParamConverter $configuration)
 {
     $options = (array) $configuration->getOptions();
     if (isset($options['deserializationContext']) && is_array($options['deserializationContext'])) {
         $arrayContext = array_merge($this->context, $options['deserializationContext']);
     } else {
         $arrayContext = $this->context;
     }
     $this->configureContext($context = new Context(), $arrayContext);
     try {
         $object = $this->serializer->deserialize($request->getContent(), $configuration->getClass(), $request->getContentType(), $context);
     } catch (UnsupportedFormatException $e) {
         throw new UnsupportedMediaTypeHttpException($e->getMessage(), $e);
     } catch (JMSSerializerException $e) {
         throw new BadRequestHttpException($e->getMessage(), $e);
     } catch (SymfonySerializerException $e) {
         throw new BadRequestHttpException($e->getMessage(), $e);
     }
     $request->attributes->set($configuration->getName(), $object);
     if (null !== $this->validator) {
         $validatorOptions = $this->getValidatorOptions($options);
         $errors = $this->validator->validate($object, null, $validatorOptions['groups']);
         $request->attributes->set($this->validationErrorsArgument, $errors);
     }
     return true;
 }
开发者ID:rokkie,项目名称:FOSRestBundle,代码行数:29,代码来源:RequestBodyParamConverter.php

示例8: apply

 /**
  * {@inheritdoc}
  *
  * @throws NotFoundHttpException When invalid date given
  */
 public function apply(Request $request, ParamConverter $configuration)
 {
     $param = $configuration->getName();
     if (!$request->attributes->has($param)) {
         return false;
     }
     $options = $configuration->getOptions();
     $value = $request->attributes->get($param);
     if (!$value && $configuration->isOptional()) {
         return false;
     }
     if (isset($options['format'])) {
         $date = DateTime::createFromFormat($options['format'], $value);
         if (!$date) {
             throw new NotFoundHttpException('Invalid date given.');
         }
     } else {
         if (false === strtotime($value)) {
             throw new NotFoundHttpException('Invalid date given.');
         }
         $date = new DateTime($value);
     }
     $request->attributes->set($param, $date);
     return true;
 }
开发者ID:Dren-x,项目名称:mobit,代码行数:30,代码来源:DateTimeParamConverter.php

示例9: supports

 /**
  * {@inheritdoc}
  */
 public function supports(ParamConverter $configuration)
 {
     $options = $configuration->getOptions();
     if (isset($options['allowAnonymous'])) {
         return is_bool($options['allowAnonymous']) ? true : false;
     }
     return true;
 }
开发者ID:claroline,项目名称:distribution,代码行数:11,代码来源:CurrentUserConverter.php

示例10: supports

 /**
  * {@inheritdoc}
  */
 public function supports(ParamConverter $configuration)
 {
     $options = $configuration->getOptions();
     if (isset($options['multipleIds']) && $options['multipleIds'] === true) {
         return true;
     }
     return false;
 }
开发者ID:claroline,项目名称:distribution,代码行数:11,代码来源:MultipleIdsConverter.php

示例11: supports

 /**
  * {@inheritdoc}
  */
 public function supports(ParamConverter $configuration)
 {
     $options = $configuration->getOptions();
     if (isset($options['authenticatedUser']) && is_bool($options['authenticatedUser'])) {
         return true;
     }
     return false;
 }
开发者ID:claroline,项目名称:distribution,代码行数:11,代码来源:AuthenticatedUserConverter.php

示例12: apply

 /**
  * @param Request                $request
  * @param ParamConverter $configuration
  *
  * @return bool
  *
  * @throws \LogicException
  * @throws NotFoundHttpException
  * @throws \Exception
  */
 public function apply(Request $request, ParamConverter $configuration)
 {
     $classQuery = $configuration->getClass() . 'Query';
     $classPeer = $configuration->getClass() . 'Peer';
     $this->filters = array();
     $this->exclude = array();
     if (!class_exists($classQuery)) {
         throw new \Exception(sprintf('The %s Query class does not exist', $classQuery));
     }
     $tableMap = $classPeer::getTableMap();
     $pkColumns = $tableMap->getPrimaryKeyColumns();
     if (count($pkColumns) == 1) {
         $this->pk = strtolower($pkColumns[0]->getName());
     }
     $options = $configuration->getOptions();
     // Check route options for converter options, if there are non provided.
     if (empty($options) && $request->attributes->has('_route') && $this->router && $configuration instanceof ParamConverter) {
         $converterOption = $this->router->getRouteCollection()->get($request->attributes->get('_route'))->getOption('propel_converter');
         if (!empty($converterOption[$configuration->getName()])) {
             $options = $converterOption[$configuration->getName()];
         }
     }
     if (isset($options['mapping'])) {
         // We use the mapping for calling findPk or filterBy
         foreach ($options['mapping'] as $routeParam => $column) {
             if ($request->attributes->has($routeParam)) {
                 if ($this->pk === $column) {
                     $this->pk = $routeParam;
                 } else {
                     $this->filters[$column] = $request->attributes->get($routeParam);
                 }
             }
         }
     } else {
         $this->exclude = isset($options['exclude']) ? $options['exclude'] : array();
         $this->filters = $request->attributes->all();
     }
     $this->withs = isset($options['with']) ? is_array($options['with']) ? $options['with'] : array($options['with']) : array();
     // find by Pk
     if (false === ($object = $this->findPk($classQuery, $request))) {
         // find by criteria
         if (false === ($object = $this->findOneBy($classQuery, $request))) {
             if ($configuration->isOptional()) {
                 //we find nothing but the object is optional
                 $object = null;
             } else {
                 throw new \LogicException('Unable to guess how to get a Propel object from the request information.');
             }
         }
     }
     if (null === $object && false === $configuration->isOptional()) {
         throw new NotFoundHttpException(sprintf('%s object not found.', $configuration->getClass()));
     }
     $request->attributes->set($configuration->getName(), $object);
     return true;
 }
开发者ID:ChazalFlorian,项目名称:enjoyPangolin,代码行数:66,代码来源:PropelParamConverter.php

示例13: apply

 /**
  * Stores the object in the request.
  *
  * @param Request        $request       The request
  * @param ParamConverter $configuration Contains the name, class and options of the object
  *
  * @return bool    True if the object has been successfully set, else false
  */
 public function apply(Request $request, ParamConverter $configuration)
 {
     $options = $configuration->getOptions();
     if (!empty($options['parameters'])) {
         foreach ($options['parameters'] as $parameter) {
             $request->attributes->set($parameter, $request->get($parameter));
         }
     }
     return true;
 }
开发者ID:RomanShumkov,项目名称:EcentriaRestBundle,代码行数:18,代码来源:ParameterConverter.php

示例14: getOptions

 private function getOptions(ParamConverter $configuration)
 {
     $options = array_replace(['model' => $configuration->getClass() . 'Model'], $configuration->getOptions());
     if (isset($options['connection'])) {
         $options['session'] = $this->pomm[$options['session']];
     } else {
         $options['session'] = $this->pomm->getDefaultSession();
     }
     return $options;
 }
开发者ID:mahanhaz,项目名称:pomm-bundle,代码行数:10,代码来源:EntityParamConverter.php

示例15: apply

 /**
  * @see \Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterInterface::apply()
  */
 public function apply(Request $request, ParamConverter $configuration)
 {
     $options = $configuration->getOptions();
     $service_id = isset($options['service_id']) ? $options['service_id'] : $this->getServiceIdForClassName($configuration);
     $handler = $this->container->get($service_id);
     $class = $this->handlers[$service_id];
     if (!$handler instanceof FormHandlerInterface || get_class($handler) !== $class) {
         return;
     }
     $request->attributes->set($configuration->getName(), $handler);
 }
开发者ID:hostnet,项目名称:form-handler-bundle,代码行数:14,代码来源:FormParamConverter.php


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