-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
218 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
/** | ||
* @copyright Anton Tuyakhov <[email protected]> | ||
*/ | ||
|
||
namespace tuyakhov\notifications; | ||
|
||
use yii\helpers\Inflector; | ||
|
||
class NotificationTrait implements NotificationInterface | ||
{ | ||
public function broadcastOn() | ||
{ | ||
$channels = []; | ||
$methods = get_class_methods($this); | ||
foreach ($methods as $method) { | ||
if (($channel = stristr($method, 'exportFor', true)) !== false) { | ||
$channels[] = $channel; | ||
} | ||
} | ||
return $channels; | ||
} | ||
|
||
public function exportFor($channel) | ||
{ | ||
if (method_exists($this, $method = 'exportFor'.Inflector::id2camel($channel))) { | ||
return $this->{$method}(); | ||
} | ||
throw new \InvalidArgumentException("Cannot find message export for chanel `{$channel}`"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
/** | ||
* @copyright Anton Tuyakhov <[email protected]> | ||
*/ | ||
|
||
namespace tuyakhov\notifications\messages; | ||
|
||
|
||
class MailMessage extends AbstractMessage | ||
{ | ||
/** | ||
* The view to be used for rendering the message body. | ||
* @var string|array|null $view | ||
*/ | ||
public $view; | ||
|
||
/** | ||
* The parameters (name-value pairs) that will be extracted and made available in the view file. | ||
* @var array | ||
*/ | ||
public $viewData; | ||
|
||
/** | ||
* The message sender. | ||
* @var string | ||
*/ | ||
public $from; | ||
} |
Oops, something went wrong.