Different areas of my app need to send notifications (emails), around 20 different scenarios (so these are spread across 3 controllers).
I want to make a model Notifications and put all the functions in there. The controllers can then load the model and fire off the relevant notifications.
Each function in the Notifications model, will load the relevant models needed to send to the appropriate message.
Is this a good design? Or should this be in a Controller component? (for CakePHP 3.x)
namespace MyPlugin\Controller;
use Cake\Mailer\MailerAwareTrait;
use MyPlugin\Controller\AppController;
...
class QueryRepliesController extends AppController
{
use MailerAwareTrait;
public function add(){
...
$this->getMailer('Notification')->send('newQueryReply', [$queryReply]);
In my Mailer:
namespace App\Mailer;
use Cake\Mailer\Mailer;
class NotificationMailer extends Mailer {
public function newQueryReply($entity)
{
I get Mailer class “Notification” could not be found.
make sure your namespace are correct, namespace MyPlugin\Controller; and namespace App\Mailer; are you sure they are correct? one is from plugin and second from your app?
also you didnt give your file names they also have to be correct