Инструменты пользователя

Инструменты сайта


limb3:en:architecture:filters

Intercepting Filters Chain

Description

Intercepting filters are used to pre-process requests and post-process responses. They wrap and modify or transform inputs and outputs to/from core application logic. Intercepting Filter pattern can be applied at any level of an application. Limb uses intercepting filters as a part of FrontController. You can read more about this pattern at WACT DocuWiki - lmbInterceptingFilter

UML charts

UML Static Structure:

}

UML Sequence:

}

Comments

It's easy to control core application logic with intercepting filters. Common Limb-based application is just a filter chain and all the application needs to do is to process this chain. Your index.php file can look like this:

require_once(dirname(__FILE__) . '/setup.php');
require_once(dirname(__FILE__) . '/src/MyApplication.class.php');
 
$application = new MyApplication();
$application->process(); 

And MyApplication class:

require_once(LPKG_CORE_DIR . '/src/filter/lmbFilterChain.class.php');
 
class MyApplication extends lmbFilterChain
{
  function __construct()
  {
    $this->registerFilter(new lmbHandle(LPKG_CORE_DIR . '/src/filter/lmbTimingFilter'));
    $this->registerFilter(new lmbHandle(LPKG_CORE_DIR . '/src/filter/ResponseProcessingFilter'));
    $this->registerFilter(new lmbHandle(LPKG_CORE_DIR . '/src/filter/lmbUncaughtExceptionHandlingFilter'));
    $this->registerFilter(new lmbHandle(LPKG_CORE_DIR . '/src/filter/lmbViewRenderingFilter'));
    $this->registerFilter(new lmbHandle(LPKG_CORE_DIR . '/src/filter/lmbRequestDispatchingFilter'));
    $this->registerFilter(new lmbHandle(LPKG_CORE_DIR . '/src/filter/lmbCommandProcessingFilter'));
  }
} 

You can think about Limb filter chain as of a set of nested filters, like this:

   +-authentication filter
   |
   | +-full page cache filter
   | | 
   | | +-other filter
   | | |
   | | |_
   | | 
   | |_
   |
   |_

It's up to the filter to decide whether to pass control to the next filter or not, e.g:

class SimpleInterceptingFilter implements lmbInterceptingFilter
{      
  function run($filter_chain)
  { 
    //pre-processing is done here
 
    if ($this->someConditionPassed())
      $filter_chain->next();    
 
    //post-processing is done here
  }      
} 

Base Limb filters

NamePurpose
lmbCommandProcessingFilterExecutes a command that belongs to requested lmbService and Action
UOWFilterStarts and finishes an ORM transaction
lmbSessionStartupFilterStarts a session
lmbRequestDispatchingFilterDetermines requested lmbService and Action using lmbRequestDispatcher
lmbViewRenderingFilterRenders View that could be set somethere in lmbCommand
lmbUncaughtExceptionHandlingFilterAllows to process system errors in more «user-friendly» way

Обсуждение

Ваш комментарий. Вики-синтаксис разрешён:
  _____   ___    __ __   ___    ___ 
 / ___/  / _ |  / //_/  / _ \  / _ \
/ (_ /  / __ | / ,<    / , _/ / , _/
\___/  /_/ |_|/_/|_|  /_/|_| /_/|_|
 
limb3/en/architecture/filters.txt · Последние изменения: 2010/11/10 10:02 (внешнее изменение)