예제 #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;
 }
예제 #2
0
 private function getRequestedFilters(\blaze\netlet\http\HttpNetletRequest $request, \blaze\netlet\NetletContext $context)
 {
     $uri = $request->getRequestURI()->getPath();
     if (!$uri->endsWith('/')) {
         $uri = $uri->concat('/');
     }
     $filterArr = new \blaze\collections\lists\ArrayList();
     // Looking in the filter mapping for a filter that fits the url
     foreach ($context->getFilterMapping() 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)) {
             $filters = $context->getFilters();
             $filterArr->add($filters->get($name));
         }
     }
     return $filterArr;
 }