"Fossies" - the Fresh Open Source Software Archive

Member "neos-development-collection-7.0.1/Neos.Fusion/Classes/Core/ExceptionHandlers/ContextDependentHandler.php" (23 Feb 2021, 1466 Bytes) of package /linux/www/neos-development-collection-7.0.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ContextDependentHandler.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 namespace Neos\Fusion\Core\ExceptionHandlers;
    3 
    4 /*
    5  * This file is part of the Neos.Fusion package.
    6  *
    7  * (c) Contributors of the Neos Project - www.neos.io
    8  *
    9  * This package is Open Source Software. For the full copyright and license
   10  * information, please view the LICENSE file which was distributed with this
   11  * source code.
   12  */
   13 
   14 use Neos\Flow\Annotations as Flow;
   15 use Neos\Flow\Utility\Environment;
   16 
   17 /**
   18  * A special exception handler that is used on the outer path to catch all unhandled exceptions and uses other exception
   19  * handlers depending on the context.
   20  */
   21 class ContextDependentHandler extends AbstractRenderingExceptionHandler
   22 {
   23     /**
   24      * @Flow\Inject
   25      * @var Environment
   26      */
   27     protected $environment;
   28 
   29     /**
   30      * Handle an exception depending on the context with an HTML message or XML comment
   31      *
   32      * @param array $fusionPath path causing the exception
   33      * @param \Exception $exception exception to handle
   34      * @param integer $referenceCode
   35      * @return string
   36      */
   37     protected function handle($fusionPath, \Exception $exception, $referenceCode)
   38     {
   39         $context = $this->environment->getContext();
   40         if ($context->isDevelopment()) {
   41             $handler = new HtmlMessageHandler();
   42         } else {
   43             $handler = new XmlCommentHandler();
   44         }
   45         $handler->setRuntime($this->getRuntime());
   46         return $handler->handleRenderingException($fusionPath, $exception);
   47     }
   48 }