フィルター

フィルタークラス

apps/frontend/lib/fooFilter.class.php:

 <?php
 class fooFilter extends sfFilter
 {
     public function execute ($filterChain)
     {
         if (!$this->isFirstCall()) {
             return;
         }
 
         $filterChain->execute();
 
         $request  = $this->getContext()->getRequest();
         $response = $this->getContext()->getResponse();
 
         $contentType = $response->getContentType();
         if (strpos($contentType, 'html') === false) {
             return;
         }
 
         $html = $response->getContent();
         $html = str_replce('</body>', 'TEST</body>', $html);
         $response->setContent($html);
     }
 }

フィルター設定

frontend/config/filters.yml:

 rendering: ~
 security:  ~
 
 foofilter:
   class: fooFilter
 
 cache:     ~
 common:    ~
 execution: ~

参考

http://www.symfony-project.org/book/1_2/06-Inside-the-Controller-Layer#chapter_06_filters


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS

Last-modified: 2011-11-30 (水) 14:28:58