Skip to content

Commit

Permalink
Notification improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
bobmulder committed Sep 8, 2015
1 parent 51e153f commit 1a61be1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
12 changes: 8 additions & 4 deletions config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Settings\Core\Setting;
use Cake\Event\EventManager;
use CakeAdmin\Event\CakeAdminMailer;
use Notifier\Utility\NotificationManager;

# Plugins
Plugin::load('Utils', []);
Expand Down Expand Up @@ -59,9 +60,12 @@
Plugin::load('LightStrap', ['bootstrap' => true, 'routes' => true]);


# Notifier RecipientList
//Configure::write('Notifier.recipientLists.administrators', \Cake\ORM\TableRegistry::get('CakeAdmin.Administrators')->find('list')->toArray());
# Events
EventManager::instance()->on(new CakeAdminMailer());


# Events
EventManager::instance()->on(new CakeAdminMailer());
# Notification Templates
NotificationManager::instance()->addTemplate('newAdministrator', [
'title' => 'New administrator has been registered',
'body' => ':email has been registered as administrator at :created'
]);
9 changes: 9 additions & 0 deletions src/Controller/Component/CakeAdminComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use Cake\Controller\Component;
use Cake\Controller\ComponentRegistry;
use Cake\ORM\TableRegistry;
use Notifier\Utility\NotificationManager;

/**
* CakeAdmin component
Expand All @@ -26,6 +27,8 @@ public function initialize(array $config)
parent::initialize($config);

$this->_Controller = $this->_registry->getController();

$this->_setRecipientList();
}

public function administrators($field = null)
Expand Down Expand Up @@ -60,4 +63,10 @@ public function authUser()
}
return false;
}

protected function _setRecipientList()
{
$list = TableRegistry::get('CakeAdmin.Administrators')->find('list')->toArray();
NotificationManager::instance()->addRecipientList('administrators', $list);
}
}

0 comments on commit 1a61be1

Please sign in to comment.