Yii2 machour NotificationsWidget class not found

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Yii2 machour NotificationsWidget class not found



We are trying to run "machour" notification widget in Yii2-Advanced template. We could successfully install the extension through composer.



We are getting the following class error:
Class 'NotificationsWidget' not found.



The above problem is still existing Yii2 notification widget class not found.



We are calling following code in layouts folder:


use commonmodelsNotification;
<?php NotificationsWidget::widget([
'theme' => NotificationsWidget::THEME_GROWL,
'clientOptions' => [
'location' => 'br',
],
'counters' => [
'.notifications-header-count',
'.notifications-icon-count'
],
'markAllSeenSelector' => '#notification-seen-all',
'listSelector' => '#notifications',
]);

?>



And this is the code inside folder: common/models:


<?php
namespace commonmodels;

use Yii;
use yiibaseModel;
use yiidbExpression;
use machouryii2notificationsmodelsNotification as BaseNotification;

class Notification extends BaseNotification
{

/**
* A new message notification
*/
const KEY_NEW_MESSAGE = 'new_message';
/**
* A meeting reminder notification
*/
const KEY_MEETING_REMINDER = 'meeting_reminder';
/**
* No disk space left !
*/
const KEY_NO_DISK_SPACE = 'no_disk_space';

/**
* @var array Holds all usable notifications
*/
public static $keys = [
self::KEY_NEW_MESSAGE,
self::KEY_MEETING_REMINDER,
self::KEY_NO_DISK_SPACE,
];

/**
* @inheritdoc
*/
public function getTitle()
{
switch ($this->key) {
case self::KEY_MEETING_REMINDER:
return Yii::t('app', 'Meeting reminder');

case self::KEY_NEW_MESSAGE:
return Yii::t('app', 'You got a new message');

case self::KEY_NO_DISK_SPACE:
return Yii::t('app', 'No disk space left');
}
}

/**
* @inheritdoc
*/
public function getDescription()
{
switch ($this->key) {


case self::KEY_NO_DISK_SPACE:
// We don't have a key_id here
return 'Please buy more space immediately';
}
}

/**
* @inheritdoc
*/
public function getRoute()
{
switch ($this->key) {

case self::KEY_NO_DISK_SPACE:
return 'https://aws.amazon.com/';
};
}

}



and configuration code inside frontend/config:


'modules' => [
'redactor' => 'yiiredactorRedactorModule',
'notifications' => [
'class' => 'machouryii2notificationsNotificationsModule',
// Point this to your own Notification class
// See the "Declaring your notifications" section below
'notificationClass' => 'commonmodelsNotification',
// Allow to have notification with same (user_id, key, key_id)
// Default to FALSE
'allowDuplicate' => false,
// Allow custom date formatting in database
'dbDateFormat' => 'Y-m-d H:i:s',
// This callable should return your logged in user Id
'userId' => function() {
return Yii::$app->user->id;
}
],
],




1 Answer
1



Add NotificationsWidget class file path like


NotificationsWidget


use machouryii2notificationswidgetsNotificationsWidget;
use commonmodelsNotification;

<?php NotificationsWidget::widget([
'theme' => NotificationsWidget::THEME_GROWL,
'clientOptions' => [
'location' => 'br',
],
'counters' => [
'.notifications-header-count',
'.notifications-icon-count'
],
'markAllSeenSelector' => '#notification-seen-all',
'listSelector' => '#notifications',
]);

?>



Refer Yii2 notifications






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

Visual Studio Code: How to configure includePath for better IntelliSense results