<?php
namespace Claromentis\Projects\Subscribers;

$GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"] ?: array()) + array("_d80dee8074afbf" . "a8b9f971c6b28c6" . "975" => base64_decode("UHJvamVjdFJlc3RFeGNlcHRpb24" . "="));
use Claromentis\Core\Event\EventSubscriberInterface;
use Claromentis\Core\Http\ResponseFactory;
use Claromentis\Core\Log;
use Claromentis\Projects\Exceptions\ProjectsRestException;
use Claromentis\Projects\RestExceptionFormatter;
use Claromentis\Projects\RFC7807;
use Psr\Log\LoggerAwareTrait;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\KernelEvents;




class RestExceptionListener implements EventSubscriberInterface
{
    use LoggerAwareTrait;
    
    
    
    
    private $log_util;
    
    
    
    
    private $formatter;
    
    
    
    
    private $response;
    
    
    
    
    
    
    
    
    public function __construct(RestExceptionFormatter $formatter, Log\Util $_7f5619c3a7e3906b7342a193d7c1aad3, ?LoggerInterface $_e9abd43fa12cace21feb1774e5f75144 = null)
    {
        $this->formatter = $formatter;
        $this->log_util = $_7f5619c3a7e3906b7342a193d7c1aad3;
        $this->logger = $_e9abd43fa12cace21feb1774e5f75144;
    }
    
    
    
    
    
    
    
    public function ProjectRestException(GetResponseForExceptionEvent $_e62ca7bbb93b52cafc82da1c2aefe9ec) : void
    {
        $_c35473364fa7a050299058f332ec29c1 = $_e62ca7bbb93b52cafc82da1c2aefe9ec->getException();
        
        
        if (!$_c35473364fa7a050299058f332ec29c1 instanceof ProjectsRestException) {
            return;
        }
        if (isset($this->logger)) {
            $this->log_util->LogThrowable($_c35473364fa7a050299058f332ec29c1, $this->logger, LogLevel::NOTICE);
        }
        if ($_c35473364fa7a050299058f332ec29c1 instanceof RFC7807\RFC7807Interface) {
            $_e62ca7bbb93b52cafc82da1c2aefe9ec->setResponse($this->formatter->RestResponse($_c35473364fa7a050299058f332ec29c1));
        }
    }
    
    
    
    
    public static function getSubscribedEvents()
    {
        return [KernelEvents::EXCEPTION => [[$GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_d80dee8074afbfa8b9f971c6b28c" . "6975"], -3]]];
    }
}