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


PHP Callback::toReflection方法代码示例

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


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

示例1: run

 /**
  * @return Nette\Application\IResponse
  */
 public function run(Application\Request $request)
 {
     $this->request = $request;
     $httpRequest = $this->context->getByType('Nette\\Http\\IRequest');
     if (!$httpRequest->isAjax() && ($request->isMethod('get') || $request->isMethod('head'))) {
         $refUrl = clone $httpRequest->getUrl();
         $url = $this->context->getService('router')->constructUrl($request, $refUrl->setPath($refUrl->getScriptPath()));
         if ($url !== NULL && !$httpRequest->getUrl()->isEqual($url)) {
             return new Responses\RedirectResponse($url, Http\IResponse::S301_MOVED_PERMANENTLY);
         }
     }
     $params = $request->getParameters();
     if (!isset($params['callback'])) {
         throw new Application\BadRequestException("Parameter callback is missing.");
     }
     $params['presenter'] = $this;
     $callback = new Nette\Callback($params['callback']);
     $response = $callback->invokeArgs(Application\UI\PresenterComponentReflection::combineArgs($callback->toReflection(), $params));
     if (is_string($response)) {
         $response = array($response, array());
     }
     if (is_array($response)) {
         if ($response[0] instanceof \SplFileInfo) {
             $response = $this->createTemplate('Nette\\Templating\\FileTemplate')->setParameters($response[1])->setFile($response[0]);
         } else {
             $response = $this->createTemplate('Nette\\Templating\\Template')->setParameters($response[1])->setSource($response[0]);
         }
     }
     if ($response instanceof Nette\Templating\ITemplate) {
         return new Responses\TextResponse($response);
     } else {
         return $response;
     }
 }
开发者ID:svobodni,项目名称:web,代码行数:37,代码来源:MicroPresenter.php

示例2: callMethod

 /**
  * Calls method using autowiring.
  * @param  mixed   class, object, function, callable
  * @param  array   arguments
  * @return mixed
  */
 public function callMethod($function, array $args = array())
 {
     $callback = new Nette\Callback($function);
     return $callback->invokeArgs(Helpers::autowireArguments($callback->toReflection(), $args, $this));
 }
开发者ID:vrtak-cz,项目名称:nette-doctrine-sandbox,代码行数:11,代码来源:Container.php

示例3: resolveClass

 private function resolveClass($name, $recursive = array())
 {
     if (isset($recursive[$name])) {
         throw new Nette\InvalidArgumentException('Circular reference detected for services: ' . implode(', ', array_keys($recursive)) . '.');
     }
     $recursive[$name] = TRUE;
     $def = $this->definitions[$name];
     $factory = $this->normalizeEntity($this->expand($def->factory->entity));
     if ($def->class) {
         return $def->class;
     } elseif (is_array($factory)) {
         // method calling
         if ($service = $this->getServiceName($factory[0])) {
             if (Strings::contains($service, '\\')) {
                 // @\Class
                 throw new ServiceCreationException("Unable resolve class name for service '{$name}'.");
             }
             $factory[0] = $this->resolveClass($service, $recursive);
             if (!$factory[0]) {
                 return;
             }
         }
         $factory = new Nette\Callback($factory);
         if (!$factory->isCallable()) {
             throw new Nette\InvalidStateException("Factory '{$factory}' is not callable.");
         }
         try {
             $reflection = $factory->toReflection();
             $def->class = preg_replace('#[|\\s].*#', '', $reflection->getAnnotation('return'));
             if ($def->class && !class_exists($def->class) && $def->class[0] !== '\\' && $reflection instanceof \ReflectionMethod) {
                 $def->class = $reflection->getDeclaringClass()->getNamespaceName() . '\\' . $def->class;
             }
         } catch (\ReflectionException $e) {
         }
     } elseif ($service = $this->getServiceName($factory)) {
         // alias or factory
         if (Strings::contains($service, '\\')) {
             // @\Class
             $def->autowired = FALSE;
             return $def->class = $service;
         }
         if ($this->definitions[$service]->shared) {
             $def->autowired = FALSE;
         }
         return $def->class = $this->resolveClass($service, $recursive);
     } else {
         return $def->class = $factory;
         // class name
     }
 }
开发者ID:BroukPytlik,项目名称:agility,代码行数:50,代码来源:ContainerBuilder.php

示例4: registerListener

 /**
  * Register an event listener.
  *
  * Autodetects the callback type according to its first argument. If there is none or its class
  * is \ApiGen\Event, the callback will receive the event instance. If not, the event payload will
  * be expanded and passed as arguments. The original event will be the last argument in that case.
  *
  * @param string $originName Origin name
  * @param string $eventName Event name
  * @param \Nette\Callback $callback Registered callback
  * @param integer $priority Listener priority
  * @return \ApiGen\IEventDispatcher
  * @throws \Nette\InvalidStateException If the given origin does not exist
  */
 public function registerListener($originName, $eventName, Callback $callback, $priority = 1)
 {
     $this->updating();
     if (!isset($this->origins[$originName])) {
         throw new InvalidStateException(sprintf('Origin "%s" is not registered.', $originName));
     }
     $internalName = $this->getInternalEventName($originName, $eventName);
     $needsSorting = !isset($this->listeners[$internalName][$priority]);
     $params = $callback->toReflection()->getParameters();
     if (count($params) > 0 && $params[0]->getClassName() !== 'ApiGen\\Event') {
         $this->listeners[$internalName][$priority][] = function (Event $event) use($callback) {
             return EventDispatcher::expandEventCallback($callback, $event);
         };
     } else {
         $this->listeners[$internalName][$priority][] = $callback;
     }
     if ($needsSorting) {
         krsort($this->listeners[$internalName], SORT_NUMERIC);
     }
     return $this;
 }
开发者ID:memopower,项目名称:cakephp-api-docs,代码行数:35,代码来源:EventDispatcher.php


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