在 Mailable 中使用降价:不推荐将 $environment 传递给“CommonMarkConverter”构造函数

问题描述

我想要存档的内容:我想使用 Zammad-api 创建 Zammad 票证,但还要解析 Markdown。

为此,我创建了一个自定义渠道,以使用 Zammad 的 API 向 Zammad 帮助台系统发送通知。

这是特定的类:

<?php

namespace App\Channels;

use Illuminate\Mail\Mailable;

class ZammadMessage extends Mailable
{
    /**
     * The issuer of the ticket.
     *
     * @var string
     */
    public $from;

    /**
     * The text content of the message.
     *
     * @var string
     */
    private $content;

    public function __construct($from,$content = '')
    {
        $this->from    = $from;
        $this->content = $content;
    }

    public static function create($from = '',$content = '')
    {
        return new static($from,$content);
    }

    /**
     * Set the text content of the message.
     *
     * @param  $content
     *
     * @return $this
     */
    public function content($content)
    {
        $this->content = $content;
        return $this;
    }

    public function asMarkdown()
    {
        $this->build();
        $this->body = $this->buildView();
        return $this;
    }

    public function build()
    {
        return $this->from($this->from)
                    ->markdown('emails.contact.submitted',['data' => $this->content]);
    }

    /**
     * Set the issuer of the ticket.
     *
     * @param        $address
     * @param string $name
     *
     * @return $this
     */
    public function from($address,$name = 'null'): static
    {
        $this->from = $address;

        return $this;
    }

}

通过我的通知类使用这个类

public function toTicket($notifiable)
    {
        $address = $notifiable instanceof AnonymousNotifiable
            ? collect($notifiable->routeNotificationFor('zammad'))->first()
            : $notifiable->email;


        return ZammadMessage::create()
                            ->from($address)
                            ->content($this->content)
                            ->asMarkdown();
    }

我收到此错误:

PHP 已弃用:将 $environment 传递给“League/CommonMark/CommonMarkConverter”构造函数在 1.6 中已弃用,2.0 中将不再支持;改用 MarkdownConverter。有关详细信息,请参阅 https://commonmark.thephpleague.com/2.0/upgrading/consumers/#commonmarkconverter-and-githubflavoredmarkdownconverter-constructors。在第 43 行的 /var/www/html/vendor/league/commonmark/src/CommonMarkConverter.php 中

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)