Skip to content

Commit

Permalink
Nette 3
Browse files Browse the repository at this point in the history
  • Loading branch information
mabar authored and Milan Felix Šulc committed Jun 16, 2019
1 parent a5adf4a commit c0b8dab
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
9 changes: 5 additions & 4 deletions README.md
Expand Up @@ -29,10 +29,11 @@ Extra contribution to [`nette/mail`](https://github.com/nette/mail).

## Versions

| State | Version | Branch | Nette | PHP |
|-------------|-------------|----------|--------|--------|
| development | `^0.4` | `master` | `3.0+` | `^7.2` |
| stable | `^0.3` | `master` | `2.4` | `^7.1` |
| State | Version | Branch | Nette | PHP |
|-------------|---------|----------|-------|---------|
| dev | `^0.5` | `master` | 3.0+ | `^7.2` |
| stable | `^0.4` | `master` | 3.0+ | `^7.2` |
| stable | `^0.3` | `master` | 2.4 | `>=7.1` |

## Maintainers

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -55,7 +55,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "0.4.x-dev"
"dev-master": "0.5.x-dev"
}
}
}
12 changes: 3 additions & 9 deletions src/DI/MailExtension.php
Expand Up @@ -2,7 +2,6 @@

namespace Contributte\Mail\DI;

use Contributte\Mail\Exception\Logic\InvalidStateException;
use Contributte\Mail\Mailer\TraceableMailer;
use Contributte\Mail\Message\IMessageFactory;
use Contributte\Mail\Tracy\MailPanel;
Expand All @@ -12,7 +11,6 @@
use Nette\Schema\Expect;
use Nette\Schema\Schema;
use stdClass;
use Tracy\IBarPanel;

/**
* @property-read stdClass $config
Expand All @@ -33,8 +31,8 @@ public function getConfigSchema(): Schema
{
return Expect::structure([
'mode' => Expect::anyOf(...self::MODES)->default(self::MODE_STANDALONE),
'mailer' => Expect::type('string|' . Statement::class)->dynamic(),
'debug' => Expect::bool(interface_exists(IBarPanel::class))->default(false),
'mailer' => Expect::type('string|' . Statement::class)->dynamic()->required(),
'debug' => Expect::bool(false),
]);
}

Expand All @@ -46,15 +44,11 @@ public function loadConfiguration(): void
$builder = $this->getContainerBuilder();
$config = $this->config;

if ($config->mailer === null) {
throw new InvalidStateException(sprintf('"%s" must be configured.', $this->prefix('mailer')));
}

$builder->addFactoryDefinition($this->prefix('messageFactory'))
->setImplement(IMessageFactory::class);

// Wrap original mailer by TraceableMailer
if ($config->debug === true) {
if ($config->debug) {
$mailer = $builder->addDefinition($this->prefix('mailer.original'))
->setAutowired(false);

Expand Down

0 comments on commit c0b8dab

Please sign in to comment.