isEmpty() public method

Returns whether or not this message actually contains any data to send.
Since: 2.34.0
public isEmpty ( ) : boolean
return boolean True if message is empty, otherwise false.
Example #1
0
File: Sync.php Project: horde/horde
 /**
  * Send a message change over the wbxml stream
  *
  * @param string $id                              The uid of the message
  * @param Horde_ActiveSync_Message_Base $message  The message object
  */
 public function messageChange($id, Horde_ActiveSync_Message_Base $message)
 {
     // Just ignore any messages that are not from this collection and
     // prevent sending the same object twice in one request.
     if ($message->getClass() != $this->_currentCollection['class'] || in_array($id, $this->_seenObjects)) {
         $this->_logger->notice(sprintf('[%s] IGNORING message %s since it looks like it was already sent or does not belong to this collection. Class: %s, CurrentClass: %s', $this->_procid, $id, $message->getClass(), $this->_currentCollection['class']));
         return;
     }
     // Ignore any empty objects.
     if ($message->isEmpty()) {
         $this->_logger->notice(sprintf('[%s] IGNORING message %s since it looks like it does not contain any data. Class: %s, CurrentClass: %s', $this->_procid, $id, $message->getClass(), $this->_currentCollection['class']));
         return;
     }
     // Remember this message
     $this->_seenObjects[] = $id;
     // Specify if this is an ADD or a MODIFY change?
     if ($message->flags === Horde_ActiveSync::FLAG_NEWMESSAGE) {
         $this->_encoder->startTag(Horde_ActiveSync::SYNC_ADD);
     } else {
         $this->_encoder->startTag(Horde_ActiveSync::SYNC_MODIFY);
     }
     // Send the message
     $this->_encoder->startTag(Horde_ActiveSync::SYNC_SERVERENTRYID);
     $this->_encoder->content($id);
     $this->_encoder->endTag();
     $this->_encoder->startTag(Horde_ActiveSync::SYNC_DATA);
     try {
         $message->encodeStream($this->_encoder);
     } catch (Horde_ActiveSync_Exception $e) {
         $this->_logger->err($e);
     }
     $this->_encoder->endTag();
     $this->_encoder->endTag();
 }