Skip to content

Commit

Permalink
Merge pull request #77 from SHyx0rmZ/allow-multiple-recurrence-rules
Browse files Browse the repository at this point in the history
Allow multiple recurrence rules in an event
  • Loading branch information
markuspoerschke committed Sep 16, 2016
2 parents 2dd99c1 + 1b82164 commit da7987e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
37 changes: 37 additions & 0 deletions src/Eluceo/iCal/Component/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
*
Expand Down
2 changes: 1 addition & 1 deletion tests/Eluceo/iCal/Component/CalendarIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit da7987e

Please sign in to comment.