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


PHP PresenterComponentReflection::combineArgs方法代码示例

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


在下文中一共展示了PresenterComponentReflection::combineArgs方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: run

 /**
  * @param App\Request $request
  * @return App\IResponse
  */
 public function run(App\Request $request)
 {
     $this->request = $request;
     $this->startup();
     if (!$this->startupCheck) {
         $class = (new \ReflectionClass($this))->getMethod('startup')->getDeclaringClass()->getName();
         throw new Nette\InvalidStateException("'{$class}::startup()' or its descendant does not call parent method");
     }
     try {
         $rm = new \ReflectionMethod($this, $this->getAction());
     } catch (\ReflectionException $e) {
     }
     if (isset($e) || $rm->isAbstract() || $rm->isStatic() || !$rm->isPublic()) {
         throw new App\BadRequestException("Method '{$request->getMethod()}' not allowed", 405);
     }
     $params = $this->getParameters();
     $args = App\UI\PresenterComponentReflection::combineArgs($rm, $params);
     $response = $rm->invokeArgs($this, $args);
     if ($response === null) {
         $response = new Responses\NullResponse();
     } elseif (!$response instanceof App\IResponse) {
         throw new Nette\InvalidStateException("Action '{$this->getAction(true)}' does not return instance of Nette\\Application\\IResponse");
     }
     return $response;
 }
开发者ID:dzibma,项目名称:rest-api,代码行数:29,代码来源:Presenter.php

示例3: signalReceived

 /**
  * @param string
  */
 public function signalReceived($signal)
 {
     $methodName = sprintf('handle%s', \Nette\Utils\Strings::firstUpper($signal));
     if (!method_exists($this, $methodName)) {
         throw new \Nette\Application\UI\BadSignalException(sprintf('Method %s does not exist', $methodName));
     }
     $presenterComponentReflection = new PresenterComponentReflection(get_called_class());
     $methodReflection = $presenterComponentReflection->getMethod($methodName);
     $args = $presenterComponentReflection->combineArgs($methodReflection, $this->params);
     $methodReflection->invokeArgs($this, $args);
 }
开发者ID:nella,项目名称:forms-signal-control,代码行数:14,代码来源:SignalControl.php

示例4: run

	/**
	 * @return Nette\Application\IResponse
	 */
	public function run(Application\Request $request)
	{
		$this->request = $request;

		if ($this->httpRequest && $this->router && !$this->httpRequest->isAjax() && ($request->isMethod('get') || $request->isMethod('head'))) {
			$refUrl = clone $this->httpRequest->getUrl();
			$url = $this->router->constructUrl($request, $refUrl->setPath($refUrl->getScriptPath()));
			if ($url !== NULL && !$this->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 = $params['callback'];
		$reflection = Nette\Utils\Callback::toReflection(Nette\Utils\Callback::check($callback));
		$params = Application\UI\PresenterComponentReflection::combineArgs($reflection, $params);

		if ($this->context) {
			foreach ($reflection->getParameters() as $param) {
				if ($param->getClassName()) {
					unset($params[$param->getPosition()]);
				}
			}

			$params = Nette\DI\Helpers::autowireArguments($reflection, $params, $this->context);
			$params['presenter'] = $this;
		}

		$response = call_user_func_array($callback, $params);

		if (is_string($response)) {
			$response = array($response, array());
		}
		if (is_array($response)) {
			list($templateSource, $templateParams) = $response;
			$response = $this->createTemplate()->setParameters($templateParams);
			if (!$templateSource instanceof \SplFileInfo) {
				$response->getLatte()->setLoader(new Latte\Loaders\StringLoader);
			}
			$response->setFile($templateSource);
		}
		if ($response instanceof Application\UI\ITemplate) {
			return new Responses\TextResponse($response);
		} else {
			return $response;
		}
	}
开发者ID:nakoukal,项目名称:fakturace,代码行数:54,代码来源:MicroPresenter.php

示例5: tryCall

 /**
  * Calls public method if exists
  *
  * @param  string
  * @param  array
  *
  * @return bool  does method exist?
  */
 protected function tryCall($method, array $params)
 {
     $rc = $this->getReflection();
     if ($rc->hasMethod($method)) {
         $rm = $rc->getMethod($method);
         if ($rm->isPublic() && !$rm->isAbstract() && !$rm->isStatic()) {
             return $rm->invokeArgs($this, Application\UI\PresenterComponentReflection::combineArgs($rm, $params));
         }
     }
     return FALSE;
 }
开发者ID:ales-zrak,项目名称:assets-loader,代码行数:19,代码来源:Presenter.php

示例6: tryCall

 /**
  * Calls public method if exists.
  * @param  string
  * @param  array
  * @return bool  does method exist?
  */
 protected function tryCall($method, array $params, $class = null, $dryRun = false)
 {
     if (func_num_args() == 2) {
         $class = $this;
     }
     //$rc = $class->getReflection();
     $rc = new Nette\Application\UI\PresenterComponentReflection(get_class($class));
     if ($rc->hasMethod($method)) {
         $rm = $rc->getMethod($method);
         if ($rm->isPublic() && !$rm->isAbstract() && !$rm->isStatic()) {
             $this->checkRequirements($rm);
             if (!$dryRun) {
                 $rm->invokeArgs($class, $rc->combineArgs($rm, $params));
             }
             return TRUE;
         }
     }
     return FALSE;
 }
开发者ID:vbuilder,项目名称:framework,代码行数:25,代码来源:Control.php


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