<commit_before><?php

namespace Ojs\JournalBundle\Listeners;

use Doctrine\ORM\EntityManager;
use FOS\UserBundle\Model\UserInterface;
use Ojs\CoreBundle\Service\OjsMailer;
use Ojs\JournalBundle\Event\JournalItemEvent;
use Symfony\Bridge\Doctrine\RegistryInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Routing\RouterInterface;

abstract class AbstractJournalItemMailer implements EventSubscriberInterface
{
    /** @var OjsMailer */
    protected $ojsMailer;

    /** @var EntityManager */
    protected $em;

    /** @var UserInterface */
    protected $user;

    /** @var  RouterInterface */
    protected $router;

    /**
     * AbstractJournalItemMailer constructor.
     * @param OjsMailer $ojsMailer
     * @param RegistryInterface $registry
     * @param TokenStorageInterface $tokenStorage
     * @param RouterInterface $router
     */
    public function __construct(
        OjsMailer $ojsMailer,
        RegistryInterface $registry,
        TokenStorageInterface $tokenStorage,
        RouterInterface $router
    )
    {
        $this->ojsMailer = $ojsMailer;
        $this->em = $registry->getManager();
        $this->user = $tokenStorage->getToken()->getUser();
        $this->router = $router;
    }

    protected function sendMail(JournalItemEvent $itemEvent, $item, $action)
    {
        $journalItem = $itemEvent->getItem();
        foreach ($this->ojsMailer->getJournalRelatedUsers() as $user) {
            $this->ojsMailer->sendToUser(
                $user,<commit_msg>journal item mailer service null object based :bug: fix<commit_after><?php

namespace Ojs\JournalBundle\Listeners;

use Doctrine\ORM\EntityManager;
use FOS\UserBundle\Model\UserInterface;
use Ojs\CoreBundle\Service\OjsMailer;
use Ojs\JournalBundle\Event\JournalItemEvent;
use Symfony\Bridge\Doctrine\RegistryInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Routing\RouterInterface;

abstract class AbstractJournalItemMailer implements EventSubscriberInterface
{
    /** @var OjsMailer */
    protected $ojsMailer;

    /** @var EntityManager */
    protected $em;

    /** @var UserInterface */
    protected $user;

    /** @var  RouterInterface */
    protected $router;

    /**
     * AbstractJournalItemMailer constructor.
     * @param OjsMailer $ojsMailer
     * @param RegistryInterface $registry
     * @param TokenStorageInterface $tokenStorage
     * @param RouterInterface $router
     */
    public function __construct(
        OjsMailer $ojsMailer,
        RegistryInterface $registry,
        TokenStorageInterface $tokenStorage,
        RouterInterface $router
    )
    {
        $this->ojsMailer = $ojsMailer;
        $this->em = $registry->getManager();
        $this->user = $tokenStorage->getToken() ? $tokenStorage->getToken()->getUser(): null;
        $this->router = $router;
    }

    protected function sendMail(JournalItemEvent $itemEvent, $item, $action)
    {
        $journalItem = $itemEvent->getItem();
        foreach ($this->ojsMailer->getJournalRelatedUsers() as $user) {
            $this->ojsMailer->sendToUser(
                $user,
{'fraction_non_alphanumeric': 0.10861759425493717, 'fraction_numerical': 0.0, 'mean_word_length': 3.427814569536424, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6887773', 'n_tokens_mistral': 954, 'n_tokens_neox': 935, 'n_words': 183}