首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Mailable中使用标记:不推荐将$environment传递到"CommonMarkConverter“构造函数

在Mailable中使用标记:不推荐将$environment传递到"CommonMarkConverter“构造函数
EN

Stack Overflow用户
提问于 2021-06-27 19:01:10
回答 1查看 125关注 0票数 0

我想要存档的是:我想使用Zammad创建一个Zammad票据,但也可以解析标记。

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

这是特定的类:

代码语言:javascript
复制
<?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;
    }

}

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

代码语言:javascript
复制
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/CommonMark变换器”构造函数在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中,

EN

回答 1

Stack Overflow用户

发布于 2021-06-28 11:11:44

E_USER_DEPRECATED错误并没有停止代码执行,所以您应该能够忽略它。重复检查error_reporting设置中的php.ini和/或框架中的任何类似设置,并根据需要进行调整。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68154429

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档