PHP code example of eluhr / yii2-notification-module
1. Go to this page and download the library: Download eluhr/yii2-notification-module library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
eluhr / yii2-notification-module example snippets
use eluhr\notification\components\Notification as NotificationComponent;
use eluhr\notification\Module as NotificationModule;
...
'modules' => [
'notification' => [
'class' => NotificationModule::class
],
'translatemanager' => [
'root' => [
'@vendor/eluhr/yii2-notification-module/src'
]
]
],
'components' => [
'notification' => [
'class' => NotificationComponent::class,
'mailer' => 'mailer', // OPTIONAL: Default -> mailer
'fromEmail' => '[email protected] ' // REQUIRED
]
],
'controllerMap' => [
'migrate' => [
'migrationPath' => [
'@vendor/eluhr/yii2-notification-module/src/migrations',
]
]
]
...
ExampleModel extends ActiveRecord implements ModelChangeNotification {
/**
* @return array
*/
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['notification'] = [
'class' => ModelChangeNotification::class,
'receiverIds' => [MessageUserGroup::MESSAGE_USER_GROUP_ID_PREFIX . '1']
];
return $behaviors;
}
/**
* @return string
*/
public function subject()
{
return $this->isNewRecord ? 'New entry' : ('Updated entry #' . $this->id);
}
/**
* @return string
*/
public function text()
{
$text = Html::tag('pre', htmlentities(json_encode($this->attributes, JSON_PRETTY_PRINT)));
$text .= Html::tag('p', Html::a('Direct link',['/widgets/crud/widget-template/view','id' => $this->id], true));
return $text;
}
}