<?php

namespace KupShop\SystemInspectionBundle\InspectionWriters;

use KupShop\AdminBundle\Util\ActivityLog;
use KupShop\SystemInspectionBundle\InspectionWriters\MessageTypes\ComposerMissingMessage;
use KupShop\SystemInspectionBundle\InspectionWriters\MessageTypes\HtmlDataMessage;
use KupShop\SystemInspectionBundle\InspectionWriters\MessageTypes\SimpleMessage;
use KupShop\SystemInspectionBundle\InspectionWriters\MessageTypes\StuckOrdersMessage;

class ActivityLogWriter extends InspectionWriter
{
    public function visitComposerMissing(ComposerMissingMessage $message)
    {
        $this->activityLog->addActivityLog(
            ActivityLog::SEVERITY_ERROR,
            ActivityLog::TYPE_SECURITY,
            'Composer package missing: '.$message->getMessage()
        );
    }

    public function visitStuckOrders(StuckOrdersMessage $message)
    {
        $this->activityLog->addActivityLog(ActivityLog::SEVERITY_RECOMMENDATION, ActivityLog::TYPE_SECURITY, $message->getMessage());
    }

    public function visitSimple(SimpleMessage $message)
    {
        $this->activityLog->addActivityLog($message->getSeverity() ?? ActivityLog::SEVERITY_RECOMMENDATION, $message->getSecurity() ?? ActivityLog::TYPE_SECURITY, $message->getMessage(), $message->getData() ?: []);
    }

    public function visitHtmlData(HtmlDataMessage $message)
    {
        $this->activityLog->addHtmlActivityLog($message->getSeverity() ?? ActivityLog::SEVERITY_RECOMMENDATION, $message->getSecurity() ?? ActivityLog::TYPE_SECURITY, $message->getMessage(), $message->getData() ?: []);
    }
}
