Last active
January 13, 2016 14:14
-
-
Save lookyman/eaff5b22ee8d8bee19bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// $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