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


PHP Presenter::argsToParams方法代码示例

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


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

示例1: link

 /**
  * Generates URL to presenter.
  * @param  string   destination in format "[[[module:]presenter:]action] [#fragment]"
  * @return string
  * @throws UI\InvalidLinkException
  */
 public function link($dest, array $params = array())
 {
     if (!preg_match('~^([\\w:]+):(\\w*+)(#.*)?()\\z~', $dest, $m)) {
         throw new UI\InvalidLinkException("Invalid link destination '{$dest}'.");
     }
     list(, $presenter, $action, $frag) = $m;
     try {
         $class = $this->presenterFactory ? $this->presenterFactory->getPresenterClass($presenter) : NULL;
     } catch (InvalidPresenterException $e) {
         throw new UI\InvalidLinkException($e->getMessage(), NULL, $e);
     }
     if (is_subclass_of($class, 'Nette\\Application\\UI\\Presenter')) {
         if ($action === '') {
             $action = UI\Presenter::DEFAULT_ACTION;
         }
         if (method_exists($class, $method = $class::formatActionMethod($action)) || method_exists($class, $method = $class::formatRenderMethod($action))) {
             UI\Presenter::argsToParams($class, $method, $params);
         }
     }
     if ($action !== '') {
         $params[UI\Presenter::ACTION_KEY] = $action;
     }
     $url = $this->router->constructUrl(new Request($presenter, NULL, $params), $this->refUrl);
     if ($url === NULL) {
         unset($params[UI\Presenter::ACTION_KEY]);
         $params = urldecode(http_build_query($params, NULL, ', '));
         throw new UI\InvalidLinkException("No route for {$dest}({$params})");
     }
     return $url . $frag;
 }
开发者ID:knedle,项目名称:twitter-nette-skeleton,代码行数:36,代码来源:LinkGenerator.php

示例2: link

 /**
  * Generates URL to presenter.
  * @param  string   destination in format "[[[module:]presenter:]action] [#fragment]"
  * @return string
  * @throws UI\InvalidLinkException
  */
 public function link($dest, array $params = [])
 {
     if (!preg_match('~^([\\w:]+):(\\w*+)(#.*)?()\\z~', $dest, $m)) {
         throw new UI\InvalidLinkException("Invalid link destination '{$dest}'.");
     }
     list(, $presenter, $action, $frag) = $m;
     try {
         $class = $this->presenterFactory ? $this->presenterFactory->getPresenterClass($presenter) : NULL;
     } catch (InvalidPresenterException $e) {
         throw new UI\InvalidLinkException($e->getMessage(), NULL, $e);
     }
     if (is_subclass_of($class, UI\Presenter::class)) {
         if ($action === '') {
             $action = UI\Presenter::DEFAULT_ACTION;
         }
         if (method_exists($class, $method = $class::formatActionMethod($action)) || method_exists($class, $method = $class::formatRenderMethod($action))) {
             UI\Presenter::argsToParams($class, $method, $params, [], $missing);
             if ($missing) {
                 $rp = $missing[0];
                 throw new UI\InvalidLinkException("Missing parameter \${$rp->getName()} required by {$rp->getDeclaringClass()->getName()}::{$rp->getDeclaringFunction()->getName()}()");
             }
         } elseif (array_key_exists(0, $params)) {
             throw new UI\InvalidLinkException("Unable to pass parameters to action '{$presenter}:{$action}', missing corresponding method.");
         }
     }
     if ($action !== '') {
         $params[UI\Presenter::ACTION_KEY] = $action;
     }
     $url = $this->router->constructUrl(new Request($presenter, NULL, $params), $this->refUrl);
     if ($url === NULL) {
         unset($params[UI\Presenter::ACTION_KEY]);
         $params = urldecode(http_build_query($params, NULL, ', '));
         throw new UI\InvalidLinkException("No route for {$dest}({$params})");
     }
     return $url . $frag;
 }
开发者ID:hrach,项目名称:nette-application,代码行数:42,代码来源:LinkGenerator.php


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