ここの情報は古いです。ご理解頂いた上でお取り扱いください。

source: OpenPNE3/trunk/lib/filter/sfOpenPNEExecutionFilter.class.php @ 10582

Last change on this file since 10582 was 10582, checked in by ebihara, 12 years ago

#3544:changed the execution filter catches opRuntimeException now

File size: 2.2 KB
Line 
1<?php
2
3/**
4 * This file is part of the OpenPNE package.
5 * (c) OpenPNE Project (http://www.openpne.jp/)
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file and the NOTICE file that were distributed with this source code.
9 */
10
11/**
12 * sfOpenPNEExecutionFilter
13 *
14 * @package    OpenPNE
15 * @subpackage filter
16 * @author     Kousuke Ebihara <ebihara@tejimaya.com>
17 */
18class sfOpenPNEExecutionFilter extends sfExecutionFilter
19{
20  protected function handleAction($filterChain, $actionInstance)
21  {
22    $moduleName = $actionInstance->getModuleName();
23    $actionName = $actionInstance->getActionName();
24    $dispatcher = sfContext::getInstance()->getEventDispatcher();
25
26    $dispatcher->notify(new sfEvent($this, 'op_action.pre_execute_'.$moduleName.'_'.$actionName, array(
27      'moduleName'     => $moduleName,
28      'actionName'     => $actionName,
29      'actionInstance' => $actionInstance,
30    )));
31
32    try
33    {
34      $result = parent::handleAction($filterChain, $actionInstance);
35    }
36    catch (opRuntimeException $e)
37    {
38      $this->forwardToErrorAction();
39    }
40
41    $dispatcher->notify(new sfEvent($this, 'op_action.post_execute_'.$moduleName.'_'.$actionName, array(
42      'moduleName'     => $moduleName,
43      'actionName'     => $actionName,
44      'actionInstance' => $actionInstance,
45      'result'         => $result,
46    )));
47
48    return $result;
49  }
50
51  protected function executeView($moduleName, $actionName, $viewName, $viewAttributes)
52  {
53    if (sfConfig::get('app_is_mobile'))
54    {
55      foreach ($viewAttributes as $key => $attribute)
56      {
57        $this->setFormFormatterForMobile($attribute);
58        $viewAttributes[$key] = $attribute;
59      }
60    }
61
62    parent::executeView($moduleName, $actionName, $viewName, $viewAttributes);
63  }
64
65  protected function setFormFormatterForMobile(&$form)
66  {
67    if (is_array($form))
68    {
69      array_map(array($this, 'setFormFormatterForMobile'), $form);
70    }
71    elseif ($form instanceof sfForm)
72    {
73      $form->getWidgetSchema()->setFormFormatterName('mobile');
74    }
75  }
76
77  protected function forwardToErrorAction()
78  {
79    $this->context->getController()->forward('default', 'error');
80
81    throw new sfStopException();
82  }
83}
Note: See TracBrowser for help on using the repository browser.