当前位置: 首页>>代码示例>>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;未经允许,请勿转载。