AppserverIo\Appserver\ServletEngine\AbstractServletEngine::findRequestedApplication PHP Метод

findRequestedApplication() публичный Метод

Will return the found application on success and throw an exception if nothing could be found
public findRequestedApplication ( AppserverIo\Server\Interfaces\RequestContextInterface $requestContext ) : null | AppserverIo\Psr\Application\ApplicationInterface
$requestContext AppserverIo\Server\Interfaces\RequestContextInterface Context of the current request
Результат null | AppserverIo\Psr\Application\ApplicationInterface
    public function findRequestedApplication(RequestContextInterface $requestContext)
    {
        // prepare the request URL we want to match
        $webappsDir = $this->getServerContext()->getServerConfig()->getDocumentRoot();
        $relativeRequestPath = strstr($requestContext->getServerVar(ServerVars::DOCUMENT_ROOT) . $requestContext->getServerVar(ServerVars::X_REQUEST_URI), $webappsDir);
        $proposedAppName = strstr(str_replace($webappsDir . '/', '', $relativeRequestPath), '/', true);
        // try to match a registered application with the passed request
        foreach ($this->applications as $application) {
            if ($application->getName() === $proposedAppName) {
                return $application;
            }
        }
        // if we did not find anything we should throw a bad request exception
        throw new BadRequestException(sprintf('Can\'t find application for URL %s%s', $requestContext->getServerVar(ServerVars::HTTP_HOST), $requestContext->getServerVar(ServerVars::X_REQUEST_URI)), 404);
    }