本文整理汇总了PHP中Nette\Application\UI\Control::__call方法的典型用法代码示例。如果您正苦于以下问题:PHP Control::__call方法的具体用法?PHP Control::__call怎么用?PHP Control::__call使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Application\UI\Control
的用法示例。
在下文中一共展示了Control::__call方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __call
public function __call($name, $args)
{
if (Strings::startsWith($name, 'render')) {
$this->doRenderView($this->getViewByRenderMethod($name), $args);
} else {
return parent::__call($name, $args);
}
}
示例2: __call
public function __call($name, $args)
{
if (strpos($name, 'render') !== 0) {
return parent::__call($name, $args);
}
$this->wrapRender(lcFirst(substr($name, 6)));
return NULL;
}
示例3: __call
public function __call($name, $args)
{
if (preg_match('#([[:alnum:]]+)Command#', $name, $matches)) {
$commandClassName = 'Bubo\\Commanding\\PageCommands\\' . ucfirst($matches[0]);
if (class_exists($commandClassName)) {
$reflector = new \ReflectionClass($commandClassName);
$command = $reflector->newInstanceArgs($args);
return $command->setPageManager($this->pageManager)->execute();
}
}
parent::__call($name, $args);
}
示例4: __call
/**
* @param string $name
* @param string $args
* @return mixed
*/
public function __call($name, $args)
{
if ($name === 'render') {
if (isset($args[0]) && is_array($args[0]) && isset($args[0]['config'])) {
$this->configureControl($args[0]['config']);
}
if (method_exists($this, 'renderDefault')) {
call_user_func_array(array($this, 'renderDefault'), $args);
}
$this->template->setFile($this->formatTemplateFile());
$this->template->render();
if (method_exists($this, 'afterRender')) {
call_user_func_array(array($this, 'afterRender'), array());
}
if (isset($args[0]) && is_array($args[0]) && isset($args[0]['config'])) {
$this->unconfigureControl();
}
return;
}
return parent::__call($name, $args);
}
示例5: __call
/**
* @param string $methodName
* @param array $args
*
* @return mixed
* @throws Nette\Application\BadRequestException
*/
public function __call($methodName, $args)
{
if (Strings::startsWith($methodName, 'render')) {
$subMethod = lcfirst(Strings::replace($methodName, '~render(\\w*)~', '\\1'));
$files = $this->formatTemplateFiles($subMethod);
foreach ($files as $file) {
if (is_file($file)) {
$this->template->setFile($file);
break;
}
}
if (!$this->template->getFile()) {
$file = preg_replace('#^.*([/\\\\].{1,70})\\z#U', "…\$1", reset($files));
$file = strtr($file, '/', DIRECTORY_SEPARATOR);
throw new Nette\Application\BadRequestException("Page not found. Missing template '{$file}'.");
}
$this->tryCall("prepare{$subMethod}", (array) @$args[0]);
$this->tryCall('beforeRender', []);
$this->template->render();
} else {
return parent::__call($methodName, $args);
}
}
示例6: __call
public function __call($name, $arguments = [])
{
if (Nette\Utils\Strings::startsWith($name, self::RENDER_METHOD)) {
$rendering = $this->isRendering();
$arguments = current($arguments) ?: $arguments;
$arguments = (array) $arguments + ['snippet' => !$rendering, 'echo' => TRUE];
$name = lcfirst(Nette\Utils\Strings::substring($name, strlen(self::RENDER_METHOD))) ?: $this->view;
$isAjax = $this->getPresenter()->isAjax();
$payload = $this->getPresenter()->getPayload();
$defaultView = $this->view;
$defaultSnippetMode = $this->snippetMode;
$views = $this->views;
if ($rendering || !$isAjax) {
$views = array_intersect_key($views, [$name => TRUE]);
} elseif ($this->snippetMode) {
$views = array_intersect_key($views, $this->invalidViews);
}
$this->isRendering(TRUE);
foreach (array_diff_key($views, $this->rendered) as $view => $snippetMode) {
$this->view = $view;
$this->snippetMode = $isAjax && !$snippetMode;
if ($this->cache && is_callable($snippetMode)) {
$dependencies = [Nette\Caching\Cache::TAGS => [], Nette\Caching\Cache::FILES => []];
$key = $this->getCacheKey();
$providers = [];
foreach ($snippetMode(...[&$dependencies]) as $dependency) {
if ($dependency instanceof Ytnuk\Cache\Provider) {
$providers[] = $dependency;
$key[] = $dependency->getCacheKey();
} else {
$key[] = $dependency;
}
}
list($output, $this->related) = $this->cache->load($key, function (&$dp) use(&$dependencies, $providers) {
foreach ($providers as $provider) {
if ($provider instanceof Ytnuk\Cache\Provider) {
$dependencies[Nette\Caching\Cache::TAGS] = array_merge($dependencies[Nette\Caching\Cache::TAGS], $provider->getCacheTags());
}
}
$dependencies[Nette\Caching\Cache::TAGS] = array_merge($dependencies[Nette\Caching\Cache::TAGS], $this->getCacheTags());
$dependencies[Nette\Caching\Cache::TAGS][] = static::class;
$output = $this->render();
$dependencies[Nette\Caching\Cache::FILES][] = $this->getTemplate()->getFile();
$dp = $dependencies;
return [$output, $this->related];
});
} else {
$output = $this->render();
}
if ($snippetMode && $isAjax) {
$payload->snippets[$this->getSnippetId()] = $output;
}
if ($control = $this->lookupRendering()) {
$control->setRelated($this, $this->view);
}
$this->rendered[$view] = $output;
}
$this->view = $defaultView;
foreach ($this->related[$this->view] as $subName => $subViews) {
$related = $this[$subName] ?? NULL;
if ($related instanceof Nette\Application\UI\IRenderable) {
$related->redrawControl();
}
}
$output = NULL;
if ($this->snippetMode = $defaultSnippetMode) {
Nette\Bridges\ApplicationLatte\UIRuntime::renderSnippets($this);
} elseif (array_key_exists($this->view = $name, $this->rendered)) {
$output = $this->rendered[$this->view];
if (!$isAjax) {
foreach ($this->related[$this->view] as $relatedName => $relatedViews) {
$related = $this->getComponent($relatedName);
if ($related instanceof self) {
foreach ($relatedViews as $relatedView => $relatedSnippetId) {
$relatedSnippet = Nette\Utils\Html::el(is_string($arguments['snippet']) ? $arguments['snippet'] : 'div', ['id' => $relatedSnippetId]);
if (strpos($output, (string) $relatedSnippet) !== FALSE) {
$output = str_replace((string) $relatedSnippet, $relatedSnippet->setHtml($related->__call(self::RENDER_METHOD . ucfirst($relatedView), ['echo' => FALSE, 'snippet' => FALSE])), $output);
}
}
}
}
}
if ($arguments['snippet'] && $this->views[$this->view] && ($snippetId = $this->getSnippetId())) {
$snippet = Nette\Utils\Html::el(is_string($arguments['snippet']) ? $arguments['snippet'] : 'div', ['id' => $snippetId]);
if ($isAjax && $this->related[$this->view]) {
$snippetMode = $this->snippetMode;
Nette\Bridges\ApplicationLatte\UIRuntime::renderSnippets($this);
$this->snippetMode = $snippetMode;
}
if ($isAjax && !isset($payload->snippets[$snippetId]) || !$isAjax && !$this->lookupRendering()) {
$snippet->setHtml($output);
}
$output = $snippet->render();
}
if ($arguments['echo']) {
echo $output;
}
$this->view = $defaultView;
}
$this->isRendering(FALSE);
//.........这里部分代码省略.........
示例7: __call
/**
* render method hook
*
* @param $func
* @param array $args
* @return mixed|void
*/
public function __call($func, $args = [])
{
if (Strings::startsWith($func, 'render')) {
$tmp = @array_reduce($args, 'array_merge', []);
// @ - intentionally
if ($tmp === NULL) {
$tmp = $args;
}
return $this->run(Strings::substring($func, 6), $tmp);
}
return parent::__call($func, $args);
}
示例8: __call
/**
*
* @param string $name
* @param array $args
*/
public function __call($methodName, $args)
{
if (Nette\Utils\Strings::startsWith($methodName, 'render')) {
// Signaly maji prednost pred view ze sablony
if (!$this->actionHandled) {
$this->changeView(lcfirst(substr($methodName, 6)));
return call_user_func_array(array($this, 'render'), $args);
} else {
$this->render();
}
return;
}
return parent::__call($methodName, $args);
}
示例9: __call
/**
* Mediates standard functions from \Nette\Application\UI\Form
*
* @param $name
* @param $arguments
*
* @return mixed|void
*/
public function __call($name, $arguments)
{
if (method_exists($this->form, $name)) {
return call_user_func_array($this->form->{$name}, $arguments);
}
parent::__call($name, $arguments);
}