HEX
Server: Apache
System: Linux WWW 6.1.0-40-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.153-1 (2025-09-20) x86_64
User: web11 (1011)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /var/www/apklausos/tests/data/plugins/DummyMailer.php
<?php

class DummyMailer extends PluginBase
{
    protected static $description = 'Marks all emails as sent';
    protected static $name = 'DummyMailer';

    private $errorToReturn = null;

    /** @inheritdoc this plugin didn't have any public method */
    public $allowedPublicMethods = array();

    public function init()
    {
        $this->subscribe('beforeEmail', 'beforeEmail');
        $this->subscribe('beforeSurveyEmail', 'beforeEmail');
        $this->subscribe('beforeTokenEmail', 'beforeEmail');
    }

    public function beforeEmail()
    {
        $event = $this->getEvent();
        $event->set('send', false);
        $event->set('error', $this->errorToReturn);
    }

    public function setError($error)
    {
        $this->errorToReturn = $error;
    }

    public function reset()
    {
        $this->errorToReturn = null;
    }
}