<?php
namespace Claromentis\Projects\Subscribers;

$GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"] ?: array()) + array("_d80dee8074" . "afbfa8b9f97" . "1c6b28c6975" => base64_decode("UHJvamVjdFJlc3RFe" . "GNlcHRpb24="));
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\ExceptionEvent;
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(ExceptionEvent $_e62ca7bbb93b52cafc82da1c2aefe9ec) : void
    {
        $_c35473364fa7a050299058f332ec29c1 = $_e62ca7bbb93b52cafc82da1c2aefe9ec->getThrowable();
        
        
        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["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_d80dee8074afbfa8b9f971c6b28c6" . "975"], -3]]];
    }
}