<?php

namespace domain\Producer\Producer;

use domain\_\AbstractResolver;
use domain\Setting\AdminSettingBag;

class ProducerResolver extends AbstractResolver
{
    public function isAlertMessageDisplayed(Producer $producer): bool
    {
        // @TODO : modifier le chargement de cette classe quand la hiérarchie des services sera revue
        $alertMessageUpdatedAt = AdminSettingBag::getInstance()->get('adminAlertMessageUpdatedAt');
        $alertMessageReadAt = $producer->getAlertMessageReadAt();

        if($alertMessageUpdatedAt) {
            $alertMessageUpdatedAt = new \DateTime($alertMessageUpdatedAt);
            if($alertMessageReadAt && $alertMessageReadAt >= $alertMessageUpdatedAt) {
                return false;
            }
        }

        return true;
    }
}