<?php
namespace Claromentis\Infocapture\Subscriber;

$GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"] ?: array()) + array("aggregatio" . "n" => base64_decode("YWdnc" . "mVnYX" . "Rpb24" . "="), "_085a57daeaa7eb01c5adc7d49" . "56ca1ec" => base64_decode("T25MaW" . "tl"), "_d0407c81" . "4a49347e4" . "4aeaf3f78" . "56927f" => base64_decode("T25Vbmxpa" . "2U="), "_da9102682d361b8bbba479d" . "d35a6a5a6" => base64_decode("bGlrZV9jb3Vu" . "dA=="), "object" . "_id" => base64_decode("b2J" . "qZW" . "N0X" . "2lk"));
use Claromentis\Core\Event\EventSubscriberInterface;
use Claromentis\Core\Event\GenericEvent;
use Claromentis\Core\Like\LikeEvents;
use Claromentis\Core\Like\LikesRepository;
use HDIssue;




class TicketLikeSubscriber implements EventSubscriberInterface
{
    
    
    
    
    private $likes_repo;
    
    
    
    
    private HDIssue $hd_issue;
    public function __construct(LikesRepository $_d9545fdd786c9a15186743b3fd0af9ff, HDIssue $_4ada5869286e9a58f9116abae0cfae31)
    {
        $this->likes_repo = $_d9545fdd786c9a15186743b3fd0af9ff;
        $this->hd_issue = $_4ada5869286e9a58f9116abae0cfae31;
    }
    public static function getSubscribedEvents() : array
    {
        return [LikeEvents::OBJECT_LIKED => $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_085a57daeaa7eb01c5adc7d4956ca" . "1ec"], LikeEvents::OBJECT_UNLIKED => $GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_d0407c814a49" . "347e44aeaf3f7" . "856927f"]];
    }
    public function OnLike(GenericEvent $event)
    {
        if (!$this->isIssueLikeEvent($event)) {
            return;
        }
        $_7c7f9b97a77342fe69e4b9ce8802e8d1 = $this->updateLikeCountProperty($event->getArgument($GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["objec" . "t_id"]));
    }
    public function OnUnlike(GenericEvent $event)
    {
        if (!$this->isIssueLikeEvent($event)) {
            return;
        }
        $_7c7f9b97a77342fe69e4b9ce8802e8d1 = $this->updateLikeCountProperty($event->getArgument($GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["object_" . "id"]));
    }
    
    
    
    
    
    private function updateLikeCountProperty(int $_39638557be821c8556d28efa25c94ff1) : bool
    {
        $_da9102682d361b8bbba479dd35a6a5a6 = $this->likes_repo->GetCount(AGGREGATION_IC_ISSUE, $_39638557be821c8556d28efa25c94ff1);
        $this->hd_issue->Load($_39638557be821c8556d28efa25c94ff1);
        $this->hd_issue->SetProperty($GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_da9102682d361b8bbba479dd3" . "5a6a5a6"], $_da9102682d361b8bbba479dd35a6a5a6);
        return $this->hd_issue->Save();
    }
    
    
    
    
    
    private function isIssueLikeEvent(GenericEvent $event) : bool
    {
        return $event->hasArgument($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["aggregati" . "on"]) && $event->getArgument($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["aggre" . "gatio" . "n"]) === AGGREGATION_IC_ISSUE;
    }
}