Skip to content

Commit

Permalink
add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
klimov-paul committed May 10, 2024
1 parent a97757d commit be1f470
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
*
* @see https://symfony.com/doc/current/mailer.html
*
* @property \Symfony\Component\Mailer\Transport\TransportInterface|\Closure|string $transport mail transport to be used.
* @property \yii1tech\mailer\View|array|string $view view instance to be used for template rendering.
* @property \Symfony\Component\Mailer\Mailer $symfonyMailer related Symfony mailer instance.
*
* @author Paul Klimov <[email protected]>
* @since 1.0
*/
Expand All @@ -59,7 +63,7 @@ class Mailer extends CApplicationComponent
* - 'smtp://user:[email protected]:25'
* - 'sendmail://default'
*
* Note: this property will have no effect in case {@see $transport} property is explicitly set.
* > Note: this property will have no effect in case {@see $transport} property is explicitly set.
*/
public $dsn;

Expand All @@ -78,7 +82,7 @@ class Mailer extends CApplicationComponent
public $defaultHeaders = [];

/**
* @var \Symfony\Component\Mailer\Mailer Swift mailer instance.
* @var \Symfony\Component\Mailer\Mailer Symfony mailer instance.
*/
private $_symfonyMailer;

Expand Down Expand Up @@ -115,13 +119,24 @@ public function send(RawMessage $message, ?Envelope $envelope = null): void
$this->getSymfonyMailer()->send($message, $envelope);
}

/**
* Sets the Symfony mailer to be used directly.
*
* Using this method makes {@see $dsn} and {@see $transport} values to be ignored.
*
* @param \Symfony\Component\Mailer\Mailer|null $symfonyMailer Symfony mailer instance.
* @return static self reference.
*/
public function setSymfonyMailer(?SymfonyMailer $symfonyMailer): self
{
$this->_symfonyMailer = $symfonyMailer;

return $this;
}

/**
* @return \Symfony\Component\Mailer\Mailer Symfony mailer instance.
*/
public function getSymfonyMailer(): SymfonyMailer
{
if ($this->_symfonyMailer === null) {
Expand All @@ -131,12 +146,19 @@ public function getSymfonyMailer(): SymfonyMailer
return $this->_symfonyMailer;
}

/**
* Creates default Symfony mailer instance with pre-configured transport.
*
* @return \Symfony\Component\Mailer\Mailer Symfony mailer instance.
*/
protected function createSymfonyMailer(): SymfonyMailer
{
return new SymfonyMailer($this->getTransport());
}

/**
* Sets the mail transport to be used.
*
* @param \Symfony\Component\Mailer\Transport\TransportInterface|\Closure|string|null $transport transport instance or its class name or factory PHP callback.
* @return static self reference.
*/
Expand All @@ -148,6 +170,8 @@ public function setTransport($transport): self
}

/**
* Returns the configured mail transport.
*
* @return \Symfony\Component\Mailer\Transport\TransportInterface mail transport instance.
*/
public function getTransport(): TransportInterface
Expand Down

0 comments on commit be1f470

Please sign in to comment.