Esempio n. 1
0
 private function internalDoFilter(\Symfony\Component\HttpFoundation\Request $request, \Symfony\Component\HttpFoundation\Response $response)
 {
     // For each filter wrap until at the end, invoke, and then return back through each filter
     if ($this->currentPosition < count($this->filterConfigs)) {
         $filterConfig = $this->filterConfigs[$this->currentPosition++];
         try {
             $filter = $filterConfig->getFilter();
             $filter->doFilter($request, $response, $this);
         } catch (\Exception $e) {
             //                $log = Serphlet_Util_Logger_Manager::getLogger(__CLASS__);
             //                $log->error('internalDoFilter caused exception ' . $e->getMessage());
             throw $e;
         }
         return;
     }
     // At the end of chaining, invoke the process
     \Serphlet\Application\FilterChain::servletProcess($request, $response, $this->servlet);
 }
Esempio n. 2
0
 /**
  * The main function for processing the current request from PHP
  */
 public function process($basePath = null)
 {
     try {
         ob_start();
         // Initialise
         self::init($basePath);
         // TODO: Identify the servlet
         $this->servlet = self::map();
         if (empty($this->servlet)) {
             throw new \Serphlet\Exception\UnavailableException('Servlet not available for this request');
         }
         // Initialise the servlet
         $this->servlet->init($this->config);
         // Configure the filter configurations
         $this->servlet->getServletConfig()->getServletContext()->filterStart();
         // Create a filter chain
         $filterFactory = \Serphlet\Application\FilterFactory::getInstance();
         $filterChain = $filterFactory->createFilterChain($this->request, $this->servlet);
         // Do filters prior to processing the modules
         if ($filterChain != null) {
             $filterChain->doFilter($this->request, $this->response);
         } else {
             \Serphlet\Application\FilterChain::servletProcess($this->request, $this->response, $this->servlet);
         }
         // Release filters
         $this->servlet->getServletConfig()->getServletContext()->filterStop();
         // TODO: Consider the location of this dispatch forward!
         if (!$this->response->isCommitted() && $this->response->isError()) {
             \Serphlet\Application\RequestDispatcherForward::commit($this->request, $this->response, $this->context);
         }
         // Flush the response
         $this->response->flushBuffer();
         // TODO: Shutdown
     } catch (Exception $e) {
         self::gracefulDie($e);
     }
 }