Skip to content

Commit

Permalink
update notification trait
Browse files Browse the repository at this point in the history
  • Loading branch information
tuyakhov committed Oct 9, 2016
1 parent abdad3e commit 15c2aff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Notifier is often used as an application component and configured in the applica
'class' => '\tuyakhov\notifications\Notifier',
'channels' => [
'mail' => [
'class' => 'MailChannel',
'class' => '\tuyakhov\notifications\channels\MailChannel',
'from' => '[email protected]'
]
],
Expand Down Expand Up @@ -76,7 +76,7 @@ class InvoicePaid implements NotificationInterface

public function exportForMail() {
return Yii::createObject([
'class' => 'tuyakhov\notifications\messages\MailMessage',
'class' => '\tuyakhov\notifications\messages\MailMessage',
'view' => ['html' => 'invoice-paid'],
'viewData' => [
'invoiceNumber' => $this->invoice->id,
Expand Down
8 changes: 6 additions & 2 deletions src/NotificationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ public function broadcastOn()
$channels = [];
$methods = get_class_methods($this);
foreach ($methods as $method) {
if (($channel = stristr($method, 'exportFor', true)) !== false) {
$channels[] = $channel;
if (strpos($method, 'exportFor') === false) {
continue;
}
$channel = str_replace('exportFor', '', $method);
if (!empty($channel)) {
$channels[] = Inflector::camel2id($channel);
}
}
return $channels;
Expand Down

0 comments on commit 15c2aff

Please sign in to comment.