From 1b82164d72a9e099b8b86285ebfc6bd9de75dfdf Mon Sep 17 00:00:00 2001 From: Patrick Pokatilo Date: Mon, 29 Aug 2016 13:36:52 +0000 Subject: [PATCH] Allow multiple recurrence rules in an event --- src/Eluceo/iCal/Component/Event.php | 37 +++++++++++++++++++ .../Component/CalendarIntegrationTest.php | 2 +- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/Eluceo/iCal/Component/Event.php b/src/Eluceo/iCal/Component/Event.php index e93d506c..40a577c1 100644 --- a/src/Eluceo/iCal/Component/Event.php +++ b/src/Eluceo/iCal/Component/Event.php @@ -145,6 +145,11 @@ class Event extends Component */ protected $recurrenceRule; + /** + * @var array + */ + protected $recurrenceRules = array(); + /** * This property specifies the date and time that the calendar * information was created. @@ -304,6 +309,10 @@ public function buildPropertyBag() $propertyBag->set('RRULE', $this->recurrenceRule); } + foreach ($this->recurrenceRules as $recurrenceRule) { + $propertyBag->set('RRULE', $recurrenceRule); + } + if (null != $this->recurrenceId) { $this->recurrenceId->applyTimeSettings($this->noTime, $this->useTimezone, $this->useUtc); $propertyBag->add($this->recurrenceId); @@ -660,25 +669,53 @@ public function setStatus($status) } /** + * @deprecated Deprecated since version 0.11.0, to be removed in 1.0. Use addRecurrenceRule instead. + * * @param RecurrenceRule $recurrenceRule * * @return $this */ public function setRecurrenceRule(RecurrenceRule $recurrenceRule) { + @trigger_error('setRecurrenceRule() is deprecated since version 0.11.0 and will be removed in 1.0. Use addRecurrenceRule instead.', E_USER_DEPRECATED); + $this->recurrenceRule = $recurrenceRule; return $this; } /** + * @deprecated Deprecated since version 0.11.0, to be removed in 1.0. Use getRecurrenceRules instead. + * * @return RecurrenceRule */ public function getRecurrenceRule() { + @trigger_error('getRecurrenceRule() is deprecated since version 0.11.0 and will be removed in 1.0. Use getRecurrenceRules instead.', E_USER_DEPRECATED); + return $this->recurrenceRule; } + /** + * @param RecurrenceRule $recurrenceRule + * + * @return $this + */ + public function addRecurrenceRule(RecurrenceRule $recurrenceRule) + { + $this->recurrenceRules[] = $recurrenceRule; + + return $this; + } + + /** + * @return array + */ + public function getRecurrenceRules() + { + return $this->recurrenceRules; + } + /** * @param $dtStamp * diff --git a/tests/Eluceo/iCal/Component/CalendarIntegrationTest.php b/tests/Eluceo/iCal/Component/CalendarIntegrationTest.php index eb869af8..399bdcc0 100644 --- a/tests/Eluceo/iCal/Component/CalendarIntegrationTest.php +++ b/tests/Eluceo/iCal/Component/CalendarIntegrationTest.php @@ -26,7 +26,7 @@ public function testExample3() $recurrenceRule = new \Eluceo\iCal\Property\Event\RecurrenceRule(); $recurrenceRule->setFreq(\Eluceo\iCal\Property\Event\RecurrenceRule::FREQ_YEARLY); $recurrenceRule->setInterval(1); - $vEvent->setRecurrenceRule($recurrenceRule); + $vEvent->addRecurrenceRule($recurrenceRule); // Adding Timezone (optional) $vEvent->setUseTimezone(true);