當前位置: 首頁>>代碼示例>>PHP>>正文


PHP sfException類代碼示例

本文整理匯總了PHP中sfException的典型用法代碼示例。如果您正苦於以下問題:PHP sfException類的具體用法?PHP sfException怎麽用?PHP sfException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了sfException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: dispatch

 /**
  * Dispatches a request.
  *
  * This will determine which module and action to use by request parameters specified by the user.
  */
 public function dispatch()
 {
     try {
         if (sfConfig::get('sf_logging_enabled')) {
             $this->getContext()->getLogger()->info('{sfController} dispatch request');
         }
         // reinitialize filters (needed for unit and functional tests)
         sfFilter::$filterCalled = array();
         // determine our module and action
         $request = $this->getContext()->getRequest();
         $moduleName = $request->getParameter('module');
         $actionName = $request->getParameter('action');
         // make the first request
         $this->forward($moduleName, $actionName);
     } catch (sfException $e) {
         if (sfConfig::get('sf_test')) {
             throw $e;
         }
         $e->printStackTrace();
     } catch (Exception $e) {
         if (sfConfig::get('sf_test')) {
             throw $e;
         }
         try {
             // wrap non symfony exceptions
             $sfException = new sfException();
             $sfException->printStackTrace($e);
         } catch (Exception $e) {
             header('HTTP/1.0 500 Internal Server Error');
         }
     }
 }
開發者ID:taryono,項目名稱:school,代碼行數:37,代碼來源:sfFrontWebController.class.php

示例2: dispatch

 /**
  * Dispatches a request.
  *
  * @param string A module name
  * @param string An action name
  * @param array  An associative array of parameters to be set
  */
 public function dispatch($moduleName, $actionName, $parameters = array())
 {
     try {
         // set parameters
         $this->getContext()->getRequest()->getParameterHolder()->add($parameters);
         // make the first request
         $this->forward($moduleName, $actionName);
     } catch (sfException $e) {
         $e->printStackTrace();
     } catch (Exception $e) {
         // wrap non symfony exceptions
         $sfException = new sfException();
         $sfException->printStackTrace($e);
     }
 }
開發者ID:jonphipps,項目名稱:Metadata-Registry,代碼行數:22,代碼來源:sfConsoleController.class.php

示例3: dispatch

 /**
  * Dispatches a request.
  *
  * This will determine which module and action to use by request parameters specified by the user.
  */
 public function dispatch()
 {
     try {
         // reinitialize filters (needed for unit and functional tests)
         sfFilter::$filterCalled = array();
         // determine our module and action
         $request = $this->context->getRequest();
         $moduleName = $request->getParameter('module');
         $actionName = $request->getParameter('action');
         if (empty($moduleName) || empty($actionName)) {
             throw new sfError404Exception(sprintf('Empty module and/or action after parsing the URL "%s" (%s/%s).', $request->getPathInfo(), $moduleName, $actionName));
         }
         // make the first request
         $this->forward($moduleName, $actionName);
     } catch (sfError404Exception $e) {
         if (!sfConfig::get('sf_web_debug')) {
             $this->forward('dmFront', 'error404');
         } else {
             $e->printStackTrace();
         }
     } catch (sfException $e) {
         $e->printStackTrace();
     } catch (Exception $e) {
         sfException::createFromException($e)->printStackTrace();
     }
 }
開發者ID:theolymp,項目名稱:diem,代碼行數:31,代碼來源:dmFrontWebController.php

示例4: printStackTrace

 /**
  * Forwards to the error action.
  */
 public function printStackTrace()
 {
     $exception = is_null($this->wrappedException) ? $this : $this->wrappedException;
     if (sfConfig::get('sf_debug')) {
         $response = sfContext::getInstance()->getResponse();
         if (is_null($response)) {
             $response = new sfWebResponse(sfContext::getInstance()->getEventDispatcher());
             sfContext::getInstance()->setResponse($response);
         }
         $response->setStatusCode($this->httpStatusCode);
         return sfException::printStackTrace();
         // skip sfError404Exception::printStackTrace()
     } else {
         // log all exceptions in php log
         if (!sfConfig::get('sf_test')) {
             error_log($this->getMessage());
         }
         if ($this->getMessage()) {
             sfContext::getInstance()->getRequest()->setParameter('error_message', $this->getMessage());
         }
         $module = sfConfig::get('sf_error_' . $this->httpStatusCode . '_module', sfConfig::get('sf_error_404_module', 'default'));
         $action = sfConfig::get('sf_error_' . $this->httpStatusCode . '_action', sfConfig::get('sf_error_404_action', 'error'));
         sfContext::getInstance()->getController()->forward($module, $action);
     }
 }
開發者ID:te-koyama,項目名稱:openpne,代碼行數:28,代碼來源:opErrorHttpException.class.php

示例5: __construct

 /**
  * Class constructor.
  *
  * @param	string	the error message
  * @param	int		the error code
  */
 public function __construct($message = null, $code = 0)
 {
     // jme- removed this function. it doesnt exist
     // - in sfExceptions.php you can find
     //   - name    = get_class($exception);
     // $this->setName('sfDateTimeException');
     parent::__construct($message, $code);
 }
開發者ID:solutema,項目名稱:siwapp-sf1,代碼行數:14,代碼來源:sfDateTimeException.class.php

示例6: dispatch

 /**
  * Dispatches a request.
  *
  * @param string $moduleName  A module name
  * @param string $actionName  An action name
  * @param array  $parameters  An associative array of parameters to be set
  */
 public function dispatch($moduleName, $actionName, $parameters = array())
 {
     try {
         // set parameters
         $this->context->getRequest()->getParameterHolder()->add($parameters);
         // make the first request
         $this->forward($moduleName, $actionName);
     } catch (sfException $e) {
         $e->printStackTrace();
     } catch (Exception $e) {
         sfException::createFromException($e)->printStackTrace();
     }
 }
開發者ID:WIZARDISHUNGRY,項目名稱:symfony,代碼行數:20,代碼來源:sfConsoleController.class.php

示例7: initialize

 /**
  * Initializes the current sfContext instance.
  *
  * @param sfApplicationConfiguration $configuration  An sfApplicationConfiguration instance
  */
 public function initialize(sfApplicationConfiguration $configuration)
 {
     $this->configuration = $configuration;
     $this->dispatcher = $configuration->getEventDispatcher();
     try {
         $this->loadFactories();
     } catch (sfException $e) {
         $e->printStackTrace();
     } catch (Exception $e) {
         sfException::createFromException($e)->printStackTrace();
     }
     $this->dispatcher->connect('template.filter_parameters', array($this, 'filterTemplateParameters'));
     // register our shutdown function
     register_shutdown_function(array($this, 'shutdown'));
 }
開發者ID:WIZARDISHUNGRY,項目名稱:symfony,代碼行數:20,代碼來源:sfContext.class.php

示例8: debug

  /**
   * Outputs some debug information about the current response.
   *
   * @param string $realOutput Whether to display the actual content of the response when an error occurred
   *                           or the exception message and the stack trace to ease debugging
   */
  public function debug($realOutput = false)
  {
    print $this->tester->error('Response debug');

    if (!$realOutput && null !== sfException::getLastException())
    {
      // print the exception and the stack trace instead of the "normal" output
      $this->tester->comment('WARNING');
      $this->tester->comment('An error occurred when processing this request.');
      $this->tester->comment('The real response content has been replaced with the exception message to ease debugging.');
    }

    printf("HTTP/1.X %s\n", $this->response->getStatusCode());

    foreach ($this->response->getHttpHeaders() as $name => $value)
    {
      printf("%s: %s\n", $name, $value);
    }

    foreach ($this->response->getCookies() as $cookie)
    {
      vprintf("Set-Cookie: %s=%s; %spath=%s%s%s%s\n", array(
        $cookie['name'],
        $cookie['value'],
        null === $cookie['expire'] ? '' : sprintf('expires=%s; ', date('D d-M-Y H:i:s T', $cookie['expire'])),
        $cookie['path'],
        $cookie['domain'] ? sprintf('; domain=%s', $cookie['domain']) : '',
        $cookie['secure'] ? '; secure' : '',
        $cookie['httpOnly'] ? '; HttpOnly' : '',
      ));
    }

    echo "\n";
    if (!$realOutput && null !== $exception = sfException::getLastException())
    {
      echo $exception;
    }
    else
    {
      echo $this->response->getContent();
    }
    echo "\n";
  }
開發者ID:nresni,項目名稱:sfBehatPlugin,代碼行數:49,代碼來源:sfBehatTesterResponse.class.php

示例9: dispatch

 /**
  * Dispatches a request.
  *
  * This will determine which module and action to use by request parameters specified by the user.
  */
 public function dispatch()
 {
     try {
         if (sfConfig::get('sf_logging_enabled')) {
             $this->dispatcher->notify(new sfEvent($this, 'application.log', array('Dispatch request')));
         }
         // reinitialize filters (needed for unit and functional tests)
         sfFilter::$filterCalled = array();
         // determine our module and action
         $request = $this->context->getRequest();
         $moduleName = $request->getParameter('module');
         $actionName = $request->getParameter('action');
         if (empty($moduleName) || empty($actionName)) {
             throw new sfError404Exception(sprintf('Empty module and/or action after parsing the URL "%s" (%s/%s).', $request->getPathInfo(), $moduleName, $actionName));
         }
         // make the first request
         $this->forward($moduleName, $actionName);
     } catch (sfException $e) {
         $e->printStackTrace();
     } catch (Exception $e) {
         sfException::createFromException($e)->printStackTrace();
     }
 }
開發者ID:ajith24,項目名稱:ajithworld,代碼行數:28,代碼來源:sfFrontWebController.class.php

示例10: preRenderCheck

 /**
  * Executes a basic pre-render check to verify all required variables exist
  * and that the template is readable.
  *
  * @throws sfRenderException If the pre-render check fails
  */
 protected function preRenderCheck()
 {
     if (null === $this->template) {
         // a template has not been set
         throw new sfRenderException('A template has not been set.');
     }
     if (!is_readable($this->directory . '/' . $this->template)) {
         // 404?
         if ('404' == $this->context->getResponse()->getStatusCode()) {
             // use default exception templates
             $this->template = sfException::getTemplatePathForError($this->context->getRequest()->getRequestFormat(), false);
             $this->directory = dirname($this->template);
             $this->template = basename($this->template);
             $this->setAttribute('code', '404');
             $this->setAttribute('text', 'Not Found');
         } else {
             throw new sfRenderException(sprintf('The template "%s" does not exist or is unreadable in "%s".', $this->template, $this->directory));
         }
     }
     // check to see if this is a decorator template
     if ($this->decorator && !is_readable($this->decoratorDirectory . '/' . $this->decoratorTemplate)) {
         throw new sfRenderException(sprintf('The decorator template "%s" does not exist or is unreadable in "%s".', $this->decoratorTemplate, $this->decoratorDirectory));
     }
 }
開發者ID:bigcalm,項目名稱:urlcatcher,代碼行數:30,代碼來源:sfView.class.php

示例11:

<?php

include sfException::getTemplatePathForError('xml', false);
開發者ID:hunde,項目名稱:bsc,代碼行數:3,代碼來源:error.atom.php

示例12: loadClass

 /**
  * Tries to load a class that has been specified in autoload.yml.
  *
  * @param  string  $class  A class name.
  *
  * @return boolean Returns true if the class has been loaded
  */
 public function loadClass($class)
 {
     $class = strtolower($class);
     // class already exists
     if (class_exists($class, false) || interface_exists($class, false)) {
         return true;
     }
     // we have a class path, let's include it
     if (isset($this->classes[$class])) {
         try {
             require $this->classes[$class];
         } catch (sfException $e) {
             $e->printStackTrace();
         } catch (Exception $e) {
             sfException::createFromException($e)->printStackTrace();
         }
         return true;
     }
     // see if the file exists in the current module lib directory
     if (sfContext::hasInstance() && ($module = sfContext::getInstance()->getModuleName()) && isset($this->classes[$module . '/' . $class])) {
         try {
             require $this->classes[$module . '/' . $class];
         } catch (sfException $e) {
             $e->printStackTrace();
         } catch (Exception $e) {
             sfException::createFromException($e)->printStackTrace();
         }
         return true;
     }
     return false;
 }
開發者ID:seven07ve,項目名稱:vendorepuestos,代碼行數:38,代碼來源:sfAutoload.class.php

示例13: dispatch

 public function dispatch()
 {
     try {
         if (sfConfig::get('sf_logging_enabled')) {
             $this->getContext()->getLogger()->info('{sfController} dispatch request');
         }
         sfFilter::$filterCalled = array();
         $request = $this->getContext()->getRequest();
         $moduleName = $request->getParameter('module');
         $actionName = $request->getParameter('action');
         $this->forward($moduleName, $actionName);
     } catch (sfException $e) {
         if (sfConfig::get('sf_test')) {
             throw $e;
         }
         $e->printStackTrace();
     } catch (Exception $e) {
         if (sfConfig::get('sf_test')) {
             throw $e;
         }
         try {
             $sfException = new sfException($e->getMessage());
             $sfException->printStackTrace($e);
         } catch (Exception $e) {
             header('HTTP/1.0 500 Internal Server Error');
         }
     }
 }
開發者ID:kotow,項目名稱:work,代碼行數:28,代碼來源:config_core_compile.yml.php

示例14: printStackTrace

  /**
   * Forwards to the 404 action.
   */
  public function printStackTrace()
  {
    $exception = null === $this->wrappedException ? $this : $this->wrappedException;

    if (sfConfig::get('sf_debug'))
    {
      $response = sfContext::getInstance()->getResponse();
      if (null === $response)
      {
        $response = new sfWebResponse(sfContext::getInstance()->getEventDispatcher());
        sfContext::getInstance()->setResponse($response);
      }

      $response->setStatusCode(404);

      return parent::printStackTrace();
    }
    else
    {
      // log all exceptions in php log
      if (!sfConfig::get('sf_test'))
      {
        error_log($this->getMessage());
      }

      sfContext::getInstance()->getController()->forward(sfConfig::get('sf_error_404_module'), sfConfig::get('sf_error_404_action'));
    }
  }
開發者ID:nationalfield,項目名稱:symfony,代碼行數:31,代碼來源:sfError404Exception.class.php

示例15: __construct

 /**
  * Class constructor.
  *
  * @param string The error message
  * @param int    The error code
  */
 public function __construct($message = null, $code = 0)
 {
     if (method_exists($this, 'setName')) {
         $this->setName('sfWebBrowserInvalidResponseException');
     }
     parent::__construct($message, $code);
 }
開發者ID:auphau,項目名稱:joyreactor,代碼行數:13,代碼來源:sfWebBrowserInvalidResponseException.class.php


注:本文中的sfException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。