本文整理汇总了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;
}
}
示例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;
}
示例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);
}
示例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;
}
}
示例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;
}
示例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;
}