0

What I want to archive: I'd like to create a Zammad ticket using the Zammad-api but also parse markdown.

To do so, I created a custom channel to send a notification to the Zammad Helpdesk system using Zammad's API.

This is the specific class:

<?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;
    }

}

Using this class by my notification class

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


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

I am getting this error:

PHP Deprecated: Passing an $environment into the "League/CommonMark/CommonMarkConverter" constructor is deprecated in 1.6 and will not be supported in 2.0; use MarkdownConverter instead. See https://commonmark.thephpleague.com/2.0/upgrading/consumers/#commonmarkconverter-and-githubflavoredmarkdownconverter-constructors for more details. in /var/www/html/vendor/league/commonmark/src/CommonMarkConverter.php on line 43

SPQRInc
  • 162
  • 4
  • 23
  • 64

1 Answers1

0

That E_USER_DEPRECATED error is not stopping code execution so you should be able to ignore it. Double-check your error_reporting setting in php.ini and/or any similar settings in your framework and adjust as needed.

Colin O'Dell
  • 8,386
  • 8
  • 38
  • 75