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


PHP ParamConverter::setName方法代码示例

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


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

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

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

示例3: 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
  * @throws \InvalidArgumentException
  */
 public function apply(Request $request, ParamConverter $configuration)
 {
     $originalName = $configuration->getName();
     if ($request->attributes->has('familyCode')) {
         $configuration->setName('familyCode');
     }
     if (!parent::apply($request, $configuration)) {
         return false;
     }
     if ($originalName !== $configuration->getName()) {
         $request->attributes->set($originalName, $request->attributes->get($configuration->getName()));
     }
     return true;
 }
开发者ID:VincentChalnot,项目名称:SidusEAVModelBundle,代码行数:23,代码来源:FamilyParamConverter.php

示例4: autoConfigure

 private function autoConfigure(\ReflectionFunctionAbstract $r, Request $request, $configurations)
 {
     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());
     }
     return $configurations;
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:19,代码来源:ParamConverterListener.php

示例5: 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')) {
         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()) {
             continue;
         }
         $name = $param->getName();
         // the parameter is already set, so disable the conversion
         if ($request->attributes->has($name)) {
             unset($configurations[$name]);
         } else {
             if (isset($configurations[$name])) {
                 $configuration = $configurations[$name];
             } else {
                 $configuration = new ParamConverter(array());
                 $configuration->setName($name);
                 $configuration->setClass($param->getClass()->getName());
             }
             $configuration->setIsOptional($param->isOptional());
             $configurations[$name] = $configuration;
         }
     }
     $this->manager->apply($request, array_values($configurations));
 }
开发者ID:rfc1483,项目名称:doctrine,代码行数:43,代码来源:ParamConverterListener.php


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