Skip to content

Instantly share code, notes, and snippets.

@lookyman
Last active January 13, 2016 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lookyman/eaff5b22ee8d8bee19bd to your computer and use it in GitHub Desktop.
Save lookyman/eaff5b22ee8d8bee19bd to your computer and use it in GitHub Desktop.
// $container instance of Nette\DI\Container
$prefixes = ['render'];
$pattern = '#^(' . implode('|', $prefixes) . ')(.+)#i';
$presenterFactory = $container->getByType(Nette\Application\IPresenterFactory::class);
if (!$presenterFactory instanceof Nette\Application\PresenterFactory) {
exit;
}
foreach ($container->findByType(Nette\Application\IPresenter::class) as $service) {
$presenter = $container->getService($service);
$presenterName = $presenterFactory->unformatPresenterClass(get_class($presenter));
if (empty($presenterName)) {
continue;
}
$ref = new ReflectionClass($presenter);
foreach ($ref->getMethods(ReflectionMethod::IS_PUBLIC | !ReflectionMethod::IS_STATIC | !ReflectionMethod::IS_ABSTRACT) as $method) {
if (!preg_match($pattern, $method->getName(), $match)) {
continue;
}
$response = $presenter->run(new Nette\Application\Request($presenterName, $match[2]));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment