[Pkg-owncloud-commits] [php-sabre-vobject] 27/106: Some refactoring.

David Prévot taffit at moszumanska.debian.org
Fri Aug 22 15:10:58 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository php-sabre-vobject.

commit 89a9fba64426c51f44d4dfa91e41768c4d7c32c7
Author: Evert Pot <evert at rooftopsolutions.nl>
Date:   Wed Jul 23 13:25:45 2014 -0400

    Some refactoring.
---
 lib/Sabre/VObject/ITip/Broker.php | 103 ++++++++++++++++++++++++--------------
 1 file changed, 65 insertions(+), 38 deletions(-)

diff --git a/lib/Sabre/VObject/ITip/Broker.php b/lib/Sabre/VObject/ITip/Broker.php
index 4f42aba..b7582cd 100644
--- a/lib/Sabre/VObject/ITip/Broker.php
+++ b/lib/Sabre/VObject/ITip/Broker.php
@@ -92,47 +92,11 @@ class Broker {
 
         switch($itipMessage->method) {
 
-            /**
-             * This is message from an organizer, and is either a new event
-             * invite, or an update to an existing one.
-             */
             case 'REQUEST' :
-                if (!$existingObject) {
-                    // This is a new invite, and we're just going to copy over
-                    // all the components from the invite.
-                    $existingObject = new VCalendar();
-                    foreach($itipMessage->message->getComponents() as $component) {
-                        $existingObject->add(clone $component);
-                    }
-                } else {
-                    // We need to update an existing object with all the new
-                    // information. We can just remove all existing components
-                    // and create new ones.
-                    foreach($existingObject->getComponents() as $component) {
-                        $existingObject->remove($component);
-                    }
-                    foreach($itipMessage->message->getComponents() as $component) {
-                        $existingObject->add(clone $component);
-                    }
-                }
-                break;
+                return $this->processMessageRequest($itipMessage, $existingObject);
 
-            /**
-             * This is a message from an organizer, and means that either an
-             * attendee got removed from an event, or an event got cancelled
-             * altogether.
-             */
             case 'CANCEL' :
-                if (!$existingObject) {
-                    // The event didn't exist in the first place, so we're just
-                    // ignoring this message.
-                } else {
-                    foreach($existingObject->VEVENT as $vevent) {
-                        $vevent->STATUS = 'CANCELLED';
-                        $vevent->SEQUENCE = $itipMessage->sequence;
-                    }
-                }
-                break;
+                return $this->processMessageCancel($itipMessage, $existingObject);
 
             /**
              * The message is a reply. This is for example an attendee telling
@@ -289,6 +253,69 @@ class Broker {
     }
 
     /**
+     * Processes incoming REQUEST messages.
+     *
+     * This is message from an organizer, and is either a new event
+     * invite, or an update to an existing one.
+     *
+     *
+     * @param Message $itipMessage
+     * @param VCalendar $existingObject
+     * @return VCalendar|bool
+     */
+    protected function processMessageRequest(Message $itipMessage, VCalendar $existingObject) {
+
+        if (!$existingObject) {
+            // This is a new invite, and we're just going to copy over
+            // all the components from the invite.
+            $existingObject = new VCalendar();
+            foreach($itipMessage->message->getComponents() as $component) {
+                $existingObject->add(clone $component);
+            }
+        } else {
+            // We need to update an existing object with all the new
+            // information. We can just remove all existing components
+            // and create new ones.
+            foreach($existingObject->getComponents() as $component) {
+                $existingObject->remove($component);
+            }
+            foreach($itipMessage->message->getComponents() as $component) {
+                $existingObject->add(clone $component);
+            }
+        }
+        return $existingObject;
+
+    }
+
+    /**
+     * Processes incoming CANCEL messages.
+     *
+     * This is a message from an organizer, and means that either an
+     * attendee got removed from an event, or an event got cancelled
+     * altogether.
+     *
+     * @param Message $itipMessage
+     * @param VCalendar $existingObject
+     * @return VCalendar|bool
+     */
+    protected function processMessageCancel(Message $itipMessage, VCalendar $existingObject) {
+
+        if (!$existingObject) {
+            // The event didn't exist in the first place, so we're just
+            // ignoring this message.
+        } else {
+            foreach($existingObject->VEVENT as $vevent) {
+                $vevent->STATUS = 'CANCELLED';
+                $vevent->SEQUENCE = $itipMessage->sequence;
+            }
+        }
+        break;
+
+        return $existingObject;
+
+    }
+
+    /**
      * This method is used in cases where an event got updated, and we
      * potentially need to send emails to attendees to let them know of updates
      * in the events.

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabre-vobject.git



More information about the Pkg-owncloud-commits mailing list