HEX
Server: Microsoft-IIS/10.0
System: Windows NT ITPWINWEBSVR22 10.0 build 20348 (Windows Server 2022) AMD64
User: www.conferencesearch.co.uk (0)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: D:/web/matomo.vdk/plugins/Marketplace/Emails/RequestTrialNotificationEmail.php
<?php

/**
 * Matomo - free/libre analytics platform
 *
 * @link https://matomo.org
 * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */

declare(strict_types=1);

namespace Piwik\Plugins\Marketplace\Emails;

use Piwik\Mail;
use Piwik\Piwik;
use Piwik\SettingsPiwik;
use Piwik\View;

class RequestTrialNotificationEmail extends Mail
{
    /**
     * @var string
     */
    private $emailAddress;

    /**
     * @var string
     */
    private $login;

    /**
     * @var string
     */
    private $pluginName;
    /**
     * @var string
     */
    private $pluginDisplayName;

    public function __construct(string $login, string $emailAddress, string $pluginName, string $pluginDisplayName)
    {
        parent::__construct();

        $this->emailAddress = $emailAddress;
        $this->login = $login;
        $this->pluginName = $pluginName;
        $this->pluginDisplayName = $pluginDisplayName;

        $this->setUpEmail();
    }

    protected function getDefaultSubject(): string
    {
        return Piwik::translate(
            'Marketplace_RequestTrialNotificationEmailSubject',
            [
                $this->pluginDisplayName,
            ]
        );
    }

    protected function getDefaultBodyView(): View
    {
        $piwikUrl = SettingsPiwik::getPiwikUrl();
        $view = new View('@Marketplace/_requestTrialNotificationEmail.twig');

        $view->login = $this->login;
        $view->marketplaceLink = $piwikUrl . 'index.php?module=Marketplace&action=overview';
        $view->pluginName = $this->pluginDisplayName;

        // @see JavaScript broadcast#propagateNewPopoverParameter
        $view->pluginLink =
            $piwikUrl
            . 'index.php?module=Marketplace&action=overview#?showPlugin=' . $this->pluginName;

        return $view;
    }

    private function setUpEmail(): void
    {
        $this->setDefaultFromPiwik();
        $this->addTo($this->emailAddress);
        $this->setSubject($this->getDefaultSubject());
        $this->addReplyTo($this->getFrom(), $this->getFromName());
        $this->setWrappedHtmlBody($this->getDefaultBodyView());
    }
}