Skip to content

Commit

Permalink
Add class to update mail configuration
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
  • Loading branch information
crynobone committed Dec 12, 2019
1 parent 7fd73b0 commit 275d64c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/Installation.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,10 @@ public function create(User $user, array $input): void
// email configuration.
$memory->put('site.name', $input['site_name']);
$memory->put('site.theme', $theme);
$memory->put('email', \config('mail'));
$memory->put('email.from', [
'name' => $input['site_name'],
'address' => $input['email'],
]);

\with(new MailConfigurationUpdater($memory), static function ($updater) use ($input) {
$updater($input['site_name'], $input['email']);
});

// We should also create a basic ACL for Orchestra Platform, since
// the basic roles is create using Fluent Query Builder we need
Expand Down
42 changes: 42 additions & 0 deletions src/MailConfigurationUpdater.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace Orchestra\Installation;

use Orchestra\Contracts\Memory\Provider;

class MailConfigurationUpdater
{
/**
* The memory implementation.
*
* @var \Orchestra\Contracts\Memory\Provider
*/
protected $memory;

/**
* Construct a new mail configuration updater.
*
* @param \Orchestra\Contracts\Memory\Provider $memory
*/
public function __construct(Provider $memory)
{
$this->memory = $memory;
}

/**
* Update mail configuration.
*
* @param string $siteName
* @param string $email
*
* @return void
*/
public function __invoke(string $siteName, string $email): void
{
$this->memory->put('email', \config('mail'));
$this->memory->put('email.from', [
'name' => $siteName,
'address' => $email,
]);
}
}

0 comments on commit 275d64c

Please sign in to comment.