Example #1
0
 /**
  * Constructor
  */
 function __construct(Config $config, array $post)
 {
     // Set config
     $this->setConfig($config);
     // If it's a message
     if ($this->isMessage($post)) {
         // Create new message
         $this->message = Loader::message($post);
         // If shortcode doesn't match
         if ($this->message->shortcode != $this->config->shortcode) {
             // Unset message
             unset($this->message);
         }
     }
     // If it's a notification
     if ($this->isNotification($post)) {
         // Create new notification
         $this->notification = Loader::notification($post);
         // If shortcode doesn't match
         if ($this->notification->shortcode != $this->config->shortcode) {
             // Unset notification
             unset($this->notification);
         }
     }
 }
Example #2
0
 /**
  * Create message
  */
 protected function createMessage($message)
 {
     // If instance of message
     if ($message instanceof Message) {
         // Return immediately
         return $message;
     } elseif (is_array($message)) {
         // If there's message instance in message
         if (isset($message['message']) && $message['message'] instanceof Message) {
             // Get message and set attributes
             return $message['message']->setAttributes(Utilities::arrayExcept(['message'], $message));
         }
     }
     // Return
     return Loader::message($message);
 }