<?php
namespace Claromentis\News\Comments;

$GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"] ?: array()) + array("_191a9c69470" . "1b5e98f9b02b" . "73105f5cf" => base64_decode("Q29tbWVudERlbGV" . "0ZWRFdmVudFJlY2" . "VpdmVy"), "_4e7af63a0a4c1e" . "afe5742f795b98e" . "323" => base64_decode("TmV3cy" . "Bjb21t" . "ZW50IC" . "M="), "_d50d529" . "d5739d10" . "3bc48e65" . "a4b513fe" . "3" => base64_decode("Q29tbWVudEFkZGVkRXZlbnRSZ" . "WNlaXZlcg=="), "_d3c72043723006" . "b659492f087ddf1" . "fdf" => base64_decode("bm" . "V3" . "cw" . "=="), "commen" . "t" => base64_decode("Y29tbWV" . "udA=="), "_2e799a34cc60c12ca876d27b" . "573a11eb" => base64_decode("IGF" . "kZG" . "Vk"), "_e8d7d52" . "7b284cad" . "d317dfbd" . "b10b34e4" . "e" => base64_decode("Q29tbWVudFVwZGF0ZWRFdmVudFJl" . "Y2VpdmVy"));
use ClaAudit;
use Claromentis\Comments\Events\CommentAddedEvent;
use Claromentis\Comments\Events\CommentDeletedEvent;
use Claromentis\Comments\Events\CommentUpdatedEvent;
use Claromentis\Comments\Model\Comment;
use Claromentis\Search\Indexing\IndexingQueue;
use Claromentis\Search\ItemType\Indexing\News;
use NewsItem;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;






class CommentsSubscriber implements EventSubscriberInterface
{
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    public static function getSubscribedEvents()
    {
        return [CommentAddedEvent::EVENT_NAME => $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_d50d529d5739d" . "103bc48e65a4b5" . "13fe3"], CommentDeletedEvent::EVENT_NAME => $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_191a9c694701b5e98f9b02b" . "73105f5cf"], CommentUpdatedEvent::EVENT_NAME => $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_e8d7d527b284cad" . "d317dfbdb10b34e4" . "e"]];
    }
    public function CommentAddedEventReceiver(CommentAddedEvent $event, $_5693d84b45564f912e36404cbe8957e8, EventDispatcherInterface $dispatcher)
    {
        
        
        $comment = $event->GetComment();
        $_60378eae7533ef2a18e2cf710db06291 = new NewsItem();
        $_60378eae7533ef2a18e2cf710db06291->Load($comment->object_id);
        if (!$_60378eae7533ef2a18e2cf710db06291->is_draft && $_60378eae7533ef2a18e2cf710db06291->IsApproved()) {
            
            
            if ((int) $comment->aggregation === AGGREGATION_NEWS) {
                IndexingQueue::Reindex(News::TYPE_NAME, $comment->object_id);
                ClaAudit::Store(AUDIT_SUCCESS, $GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_d3c72043723006b659492" . "f087ddf1fdf"], $GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["com" . "men" . "t"], $comment->object_id, $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_4e7af63a0a" . "4c1eafe5742" . "f795b98e323"] . $comment->id . $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_2e799a34c" . "c60c12ca87" . "6d27b573a1" . "1eb"]);
                $event->stopPropagation();
            }
        }
    }
    public function CommentDeletedEventReceiver(CommentDeletedEvent $event)
    {
        
        
        $comment = $event->GetComment();
        $_60378eae7533ef2a18e2cf710db06291 = new NewsItem();
        $_60378eae7533ef2a18e2cf710db06291->Load($comment->object_id);
        if (!$_60378eae7533ef2a18e2cf710db06291->is_draft && $_60378eae7533ef2a18e2cf710db06291->IsApproved()) {
            if ((int) $comment->aggregation === AGGREGATION_NEWS) {
                IndexingQueue::Reindex(News::TYPE_NAME, $comment->object_id);
                $event->stopPropagation();
            }
        }
    }
    public function CommentUpdatedEventReceiver(CommentUpdatedEvent $event)
    {
        
        
        $comment = $event->GetComment();
        $_60378eae7533ef2a18e2cf710db06291 = new NewsItem();
        $_60378eae7533ef2a18e2cf710db06291->Load($comment->object_id);
        if (!$_60378eae7533ef2a18e2cf710db06291->is_draft && $_60378eae7533ef2a18e2cf710db06291->IsApproved()) {
            if ((int) $comment->aggregation === AGGREGATION_NEWS) {
                IndexingQueue::Reindex(News::TYPE_NAME, $comment->object_id);
                $event->stopPropagation();
            }
        }
    }
}