/** * Creates a Transport instance * * @param array $config transport-specific configuration options */ public function __construct(array $config) { $config = Hash::merge(Configure::read('Notifications.transports.sms'), $config); parent::__construct($config); $keys = Configure::read('Notifications.transports.sms'); $this->_smsClient = new \WebSmsCom_Client($keys['username'], $keys['password'], $keys['gateway']); }
/** * Creates a Transport instance * * @param array $config transport-specific configuration options */ public function __construct(array $config) { parent::__construct($config); $keys = Configure::read('Notifications.transports.push_message'); if (Configure::check('Notifications.transports.push_message.' . ENVIRONMENT)) { // prefer environment specific config keys $keys = Configure::read('Notifications.transports.push_message.' . ENVIRONMENT); } ParseClient::initialize($keys['app_id'], $keys['rest_key'], $keys['master_key']); }
/** * Creates a Transport instance * * @param array $config transport-specific configuration options */ public function __construct(array $config) { parent::__construct($config); $keys = Configure::read('Notifications.transports.push_message'); ParseClient::initialize($keys['app_id'], $keys['rest_key'], $keys['master_key']); }
/** * Creates a Transport instance * * @param array $config transport-specific configuration options */ public function __construct(array $config) { $config = Hash::merge(Configure::read('Notifications.transports.email'), $config); $config = Hash::merge(['profile' => 'default', 'emailTransport' => 'default'], $config); parent::__construct($config); }
/** * Get the config from app.php and merge it with existing * @param array $config custom config */ public function __construct(array $config) { $config = Hash::merge(Configure::read('Notifications.transports.hipchat'), $config); parent::__construct($config); }
public function testTransportFactory() { $emailTransport = Transport::factory('email'); $this->assertTrue($emailTransport instanceof \Notifications\Transport\EmailTransport); $pushMessageTransport = Transport::factory('push_message'); $this->assertTrue($pushMessageTransport instanceof \Notifications\Transport\PushMessageTransport); $smsTransport = Transport::factory('sms'); $this->assertTrue($smsTransport instanceof \Notifications\Transport\SmsTransport); try { $invalidTransport = Transport::factory('invalid'); $this->fail('Transport::factory should throw an InvalidArgumentException if an invalid type is given'); } catch (\InvalidArgumentException $e) { } }
/** * Send the notification * * @param Notification $notification notification entity to be sent * @param array $transportConfig optional overriding of transport config * @return mixed */ public function send(Notification $notification, array $transportConfig = []) { $transport = Transport::factory($notification->transport, $transportConfig); $user = $this->RecipientUsers->get($notification->recipient_user_id); $model = TableRegistry::get('Notifications.NotificationContents'); $content = $model->getByIdentifier($notification->notification_identifier, $notification->locale); return $transport->sendNotification($user, $notification, $content); }