示例#1
0
 private function getRequestedNetlet(\blaze\netlet\http\HttpNetletRequest $request, \blaze\netlet\NetletContext $context)
 {
     // Making sure that the Url ends with a '/'
     $uri = $request->getRequestURI()->getPath();
     if (!$uri->endsWith('/')) {
         $uri = $uri->concat('/');
     }
     foreach ($context->getNetletMapping() as $key => $name) {
         // Make a regex placeholders of the wildcards
         $regex = '/' . strtolower(str_replace(array('/', '*'), array('\\/', '.*'), $key)) . '/';
         // Check if the requested url fits a netlet mapping
         if ($uri->matches($regex)) {
             $netlets = $context->getNetlets();
             return $netlets->get($name);
         }
     }
     return null;
 }