Example #1
0
 public function createFilterChain(\Symfony\Component\HttpFoundation\Request $request, \Serphlet\ServletInterface $servlet)
 {
     // Create and initialize a filter chain object
     $filterChain = null;
     $filterMaps = $servlet->getServletConfig()->getServletContext()->findFilterMaps();
     // If there are no filter mappings, we are done
     if ($filterMaps == null || count($filterMaps) == 0) {
         return null;
     }
     // Get the path
     //		$requestPath = $request->getParameter($servlet->getServletContext()->getServletConfig()->getPathParam());
     $requestPath = $request->getPathInfo();
     // Add the relevant path-mapped filters to this filter chain
     $n = 0;
     foreach ($filterMaps as $filterMap) {
         if (!$this->matchFiltersURL($filterMap, $requestPath, true)) {
             continue;
         }
         try {
             $filterConfig = $servlet->getServletContext()->findFilterConfig($filterMap->getFilterName());
             if ($filterConfig == null) {
                 throw new \Exception('Could not locate the filter config for the supplied filter name ' . $filterMap->getFilterName());
             }
             if ($filterChain == null) {
                 $filterChain = $this->internalCreateFilterChain($request, $servlet);
             }
             $filterChain->addFilterConfig($filterConfig);
             $n++;
         } catch (\Exception $e) {
             //                $log = Serphlet_Util_Logger_Manager::getLogger(__CLASS__);
             //                $log->error('createFilterChain() caused exception ' . $e->getMessage());
             continue;
         }
     }
     // Add filters that match on servlet name second
     foreach ($filterMaps as $filterMap) {
         if (!$this->matchFiltersServlet($filterMap, $servlet->getServletConfig()->getServletName())) {
             continue;
         }
         $filterConfig = $servlet->getServletContext()->findFilterConfig($filterMap->getFilterName());
         if ($filterConfig == null) {
             //                $log = Serphlet_Util_Logger_Manager::getLogger(__CLASS__);
             //                $log->error('createFilterChain() caused exception ' . $e->getMessage());
             continue;
         }
         if ($filterChain == null) {
             $filterChain = $this->internalCreateFilterChain($request, $servlet);
         }
         $filterChain->addFilterConfig($filterConfig);
         $n++;
     }
     // Return the completed filter chain
     return $filterChain;
 }
Example #2
0
 public function servletProcess(\Symfony\Component\HttpFoundation\Request $request, \Symfony\Component\HttpFoundation\Response $response, \Serphlet\ServletInterface $servlet)
 {
     $servlet->service($request, $response);
 }