in src/RouterCLILookupCodegenBuilder.hack [125:167]
private function getControllersForPathMethod(): CodegenMethod {
return $this->cg->codegenMethod('getControllersForPath')
->addParameter('string $path')
->setReturnTypef(
'ImmMap<\\%s, string>',
HttpMethod::class,
)
->setPrivate()
->setBody(
$this->cg->codegenHackBuilder()
->addAssignment(
'$router',
'$this->getRouter()',
HackBuilderValues::literal(),
)
->startTryBlock()
->addAssignment(
'$controllers',
'Map { }',
HackBuilderValues::literal(),
)
->startForeachLoop(
\sprintf('\\%s::getValues()', HttpMethod::class),
null,
'$method',
)
->startTryBlock()
->addLine('list($controller, $_params) =')
->indent()
->addLine('$router->routeMethodAndPath($method, $path);')
->unindent()
->addLine('$controllers[$method] = $controller;')
->addCatchBlock('\\'.MethodNotAllowedException::class, '$_')
->addInlineComment('Ignore')
->endTryBlock()
->endForeachLoop()
->addReturn('$controllers->immutable()', HackBuilderValues::literal())
->addCatchBlock('\\'.NotFoundException::class, '$_')
->addReturn('ImmMap { }', HackBuilderValues::literal())
->endTryBlock()
->getCode()
);
}