Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple recurrence rules in an event #77

Merged
merged 1 commit into from
Sep 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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