public function send(Postmaster_TransportModel $transport)
 {
     // Get the parcel schedule instance
     $parcelSchedule = $this->getParcelSchedule();
     // Check to see if the notification should send by passing the last
     // time the notification was sent as a Carbon\Carbon object
     if ($parcelSchedule->shouldSend($this->lastSent())) {
         // Get the parcel type instance
         $parcelType = $this->getParcelType();
         // Call onBeforeSend methods to the parcel schedule and parcel type
         // If either instance returns false, the message will not be sent
         if ($parcelSchedule->onBeforeSend($transport) === false) {
             return false;
         }
         if ($parcelType->onBeforeSend($transport) === false) {
             return false;
         }
         // Trigger the onBeforeSend event and allow developers one more
         // change to take over the parcel before it is sent
         $onBeforeSendEvent = $this->onBeforeSend(new Event($this, array('transport' => $transport)));
         // See if the action should still be performed and if not, return false
         if ($onBeforeSendEvent->performAction === false) {
             return false;
         }
         // Send the transport object
         $response = parent::send($transport);
         // Test the service response for correct class and throw an error if it fails
         if (!$response instanceof \Craft\Postmaster_TransportResponseModel) {
             throw new Exception('The ' . $parcelSchedule->getService()->getName() . ' service did not return a \\Craft\\Postmaster_TransportResponseModel');
         }
         // Call on the onAfterSend method for the parcel schedule
         $parcelSchedule->onAfterSend($response);
         // Call on the onAfterSend method for the parcel type
         $parcelType->onAfterSend($response);
         // Trigger the onAfterSend event to allow developers a change
         // to do something after a parcel has sent.
         $onAfterSendEvent = $this->onAfterSend(new Event($this, array('response' => $response)));
         // If the response is a success, create a parcel sent record
         if ($response->getSuccess()) {
             // Pass $this object to the createSentParcel method to
             // create the actual record in the db
             craft()->postmaster_parcels->createSentParcel($this, $response);
             // Call the onSendFailed method on the notification schedule
             $parcelSchedule->onSendComplete($response);
             // Call the onSendFailed method on the notification type
             $parcelType->onSendComplete($response);
             // Trigger the onSendFailed method
             $this->onSendComplete(new Event($this, array('response' => $response)));
         } else {
             // Call the onSendFailed method on the notification schedule
             $parcelSchedule->onSendFailed($response);
             // Call the onSendFailed method on the notification type
             $parcelType->onSendFailed($response);
             // Trigger the onSendFailed method
             $this->onSendFailed(new Event($this, array('response' => $response)));
         }
         return $response;
     }
     return false;
 }
 public function init()
 {
     parent::init();
     $this->getNotificationType()->init();
     $this->getNotificationSchedule()->init();
 }