PageRenderTime 82ms CodeModel.GetById 40ms app.highlight 3ms RepoModel.GetById 37ms app.codeStats 0ms

/public/zf-demos/Zend/Cloud/cloudexp/application/controllers/ErrorController.php

https://bitbucket.org/hieronim1981/tunethemusic
PHP | 73 lines | 36 code | 7 blank | 30 comment | 5 complexity | d7adfd3390a97641f76e033122dcb367 MD5 | raw file
 1<?php
 2/**
 3 * Zend Framework
 4 *
 5 * LICENSE
 6 *
 7 * This source file is subject to the new BSD license that is bundled
 8 * with this package in the file LICENSE.txt.
 9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
14 *
15 * @category   Zend
16 * @package    Zend_Cloud
17 * @subpackage examples
18 * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license    http://framework.zend.com/license/new-bsd     New BSD License
20 */
21
22/**
23 * @category   Zend
24 * @package    Zend_Cloud
25 * @subpackage examples
26 * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
27 * @license    http://framework.zend.com/license/new-bsd     New BSD License
28 */
29class ErrorController extends Zend_Controller_Action
30{
31    public function errorAction()
32    {
33        $errors = $this->_getParam('error_handler');
34        
35        switch ($errors->type) {
36            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
37            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
38            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
39        
40                // 404 error -- controller or action not found
41                $this->getResponse()->setHttpResponseCode(404);
42                $this->view->message = 'Page not found';
43                break;
44            default:
45                // application error
46                $this->getResponse()->setHttpResponseCode(500);
47                $this->view->message = 'Application error';
48                break;
49        }
50        
51        // Log exception, if logger available
52        if ($log = $this->getLog()) {
53            $log->crit($this->view->message, $errors->exception);
54        }
55        
56        // conditionally display exceptions
57        if ($this->getInvokeArg('displayExceptions') == true) {
58            $this->view->exception = $errors->exception;
59        }
60        
61        $this->view->request   = $errors->request;
62    }
63
64    public function getLog()
65    {
66        $bootstrap = $this->getInvokeArg('bootstrap');
67        if (!$bootstrap->hasPluginResource('Log')) {
68            return false;
69        }
70        $log = $bootstrap->getResource('Log');
71        return $log;
72    }
73}