Skip to content

Commit

Permalink
Use Flarum Paths class to determine path to assets folder
Browse files Browse the repository at this point in the history
Fixes #23
  • Loading branch information
dsevillamartin committed Jun 17, 2021
1 parent a03ac37 commit 462df82
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
13 changes: 12 additions & 1 deletion src/Mailer.php
Expand Up @@ -12,10 +12,14 @@

namespace FoF\PrettyMail;

use Flarum\Foundation\Paths;
use Flarum\Http\UrlGenerator;
use Flarum\Settings\SettingsRepositoryInterface;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Contracts\View\Factory;
use Illuminate\Mail\Mailer as LaravelMailer;
use s9e\TextFormatter\Bundles\Fatdown;
use Swift_Mailer;

class Mailer extends LaravelMailer
{
Expand All @@ -24,7 +28,14 @@ class Mailer extends LaravelMailer
*
* @var string
*/
protected $assets_dir = (__DIR__.'/../../../public/assets/');
protected $assets_dir;

public function __construct(string $name, Factory $views, Swift_Mailer $swift, Dispatcher $events = null)
{
parent::__construct($name, $views, $swift, $events);

$this->assets_dir = resolve(Paths::class)->public . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR;
}

public function raw($text, $callback, $use_fatdown = true)
{
Expand Down
7 changes: 5 additions & 2 deletions src/Overrides/NotificationMailer.php
Expand Up @@ -12,6 +12,7 @@

namespace FoF\PrettyMail\Overrides;

use Flarum\Foundation\Paths;
use Flarum\Http\UrlGenerator;
use Flarum\Notification\MailableInterface;
use Flarum\Settings\SettingsRepositoryInterface;
Expand Down Expand Up @@ -43,15 +44,17 @@ class NotificationMailer extends \Flarum\Notification\NotificationMailer
*
* @var string
*/
protected $assets_dir = (__DIR__.'/../../../../public/assets/');
protected $assets_dir;

public function __construct(Mailer $mailer, View $view, SettingsRepositoryInterface $settings, TranslatorInterface $translator, UrlGenerator $url)
public function __construct(Mailer $mailer, View $view, SettingsRepositoryInterface $settings, TranslatorInterface $translator, UrlGenerator $url, Paths $paths)
{
parent::__construct($mailer, $translator);

$this->view = $view;
$this->settings = $settings;
$this->url = $url;

$this->assets_dir = $paths->public . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR;
}

/**
Expand Down

0 comments on commit 462df82

Please sign in to comment.