Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/mautic.corals.io/app/bundles/IntegrationsBundle/EventListener/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/mautic.corals.io/app/bundles/IntegrationsBundle/EventListener/TimelineSubscriber.php
<?php

declare(strict_types=1);

namespace Mautic\IntegrationsBundle\EventListener;

use Mautic\LeadBundle\Entity\LeadEventLogRepository;
use Mautic\LeadBundle\Event\LeadTimelineEvent;
use Mautic\LeadBundle\LeadEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

class TimelineSubscriber implements EventSubscriberInterface
{
    public function __construct(
        private LeadEventLogRepository $eventLogRepository,
        private TranslatorInterface $translator
    ) {
    }

    public static function getSubscribedEvents(): array
    {
        return [
            LeadEvents::TIMELINE_ON_GENERATE => ['onTimelineGenerate', 0],
        ];
    }

    public function onTimelineGenerate(LeadTimelineEvent $event): void
    {
        $eventType     = 'integration_sync_issues';
        $eventTypeName = $this->translator->trans('mautic.integration.sync.timeline_notices');
        $event->addEventType($eventType, $eventTypeName);

        if (!$event->isApplicable($eventType)) {
            return;
        }

        $events = $this->eventLogRepository->getEvents($event->getLead(), 'integrations', null, 'sync', $event->getQueryOptions());

        // Add to counter
        $event->addToCounter($eventType, $events);

        if ($event->isEngagementCount()) {
            return;
        }

        // Add the logs to the event array
        foreach ($events['results'] as $log) {
            $event->addEvent(
                $this->getEventEntry($log, $eventType, $eventTypeName)
            );
        }
    }

    /**
     * @param mixed[] $log
     *
     * @return mixed[]
     */
    private function getEventEntry(array $log, string $eventType, string $eventTypeName): array
    {
        $properties = json_decode($log['properties'], true);

        return [
            'event'           => $eventType,
            'eventId'         => $eventType.$log['id'],
            'eventType'       => $eventTypeName,
            'eventLabel'      => $this->translator->trans(
                'mautic.integration.sync.user_notification.header',
                [
                    '%integration%' => $properties['integration'],
                    '%object%'      => $properties['object'],
                ]
            ),
            'timestamp'       => $log['date_added'],
            'icon'            => 'fa-refresh',
            'contactId'       => $log['lead_id'],
            'contentTemplate' => '@Integrations/Timeline/index.html.twig',
            'extra'           => $properties,
        ];
    }
}

Spamworldpro Mini