mirror of
https://github.com/moodle/moodle.git
synced 2025-01-31 12:45:04 +01:00
MDL-58087 core_calendar: Set correct ID for repeat event collection
Initially we were only sending "top level" events through our API i.e., events that can be repeated, but are not repeats themselves. In the future we will be sending ALL events through our API and int that situation the ID of the collection needs a small bit of logic to correctly set the ID of the parent. Part of MDL-55611 epic.
This commit is contained in:
parent
6d82ef49ea
commit
59a601e632
@ -67,11 +67,12 @@ class repeat_event_collection implements event_collection_interface {
|
||||
* Constructor.
|
||||
*
|
||||
* @param int $parentid ID of the parent event.
|
||||
* @param int $repeatid If non-zero this will be used as the parent id.
|
||||
* @param event_factory_interface $factory Event factory.
|
||||
* @throws no_repeat_parent_exception If the parent record can't be loaded.
|
||||
*/
|
||||
public function __construct($parentid, event_factory_interface $factory) {
|
||||
$this->parentid = $parentid;
|
||||
public function __construct($parentid, $repeatid, event_factory_interface $factory) {
|
||||
$this->parentid = $repeatid ? $repeatid : $parentid;
|
||||
$this->factory = $factory;
|
||||
|
||||
if (!$this->get_parent_record()) {
|
||||
|
@ -179,7 +179,7 @@ abstract class event_abstract_factory implements event_factory_interface {
|
||||
$course,
|
||||
$group,
|
||||
$user,
|
||||
new repeat_event_collection($dbrow->id, $this),
|
||||
new repeat_event_collection($dbrow->id, $dbrow->repeatid, $this),
|
||||
$module,
|
||||
$dbrow->eventtype,
|
||||
new event_times(
|
||||
|
@ -123,7 +123,7 @@ class action_event_test_factory implements event_factory_interface {
|
||||
$user->id = $id;
|
||||
return $user;
|
||||
}),
|
||||
new repeat_event_collection($record->id, $this),
|
||||
new repeat_event_collection($record->id, null, $this),
|
||||
$module,
|
||||
$record->eventtype,
|
||||
new event_times(
|
||||
|
@ -48,7 +48,7 @@ class core_calendar_repeat_event_collection_testcase extends advanced_testcase {
|
||||
$this->resetAfterTest(true);
|
||||
$parentid = 123122131;
|
||||
$factory = new core_calendar_repeat_event_collection_event_test_factory();
|
||||
$collection = new repeat_event_collection($parentid, $factory);
|
||||
$collection = new repeat_event_collection($parentid, null, $factory);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -68,7 +68,7 @@ class core_calendar_repeat_event_collection_testcase extends advanced_testcase {
|
||||
$factory = new core_calendar_repeat_event_collection_event_test_factory();
|
||||
|
||||
// Event collection with no repeats.
|
||||
$collection = new repeat_event_collection($parentid, $factory);
|
||||
$collection = new repeat_event_collection($parentid, null, $factory);
|
||||
|
||||
$this->assertEquals($parentid, $collection->get_id());
|
||||
$this->assertEquals(0, $collection->get_num());
|
||||
@ -104,7 +104,7 @@ class core_calendar_repeat_event_collection_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
// Event collection with no repeats.
|
||||
$collection = new repeat_event_collection($parentid, $factory);
|
||||
$collection = new repeat_event_collection($parentid, null, $factory);
|
||||
|
||||
$this->assertEquals($parentid, $collection->get_id());
|
||||
$this->assertEquals(count($repeats), $collection->get_num());
|
||||
@ -160,7 +160,7 @@ class core_calendar_repeat_event_collection_event_test_factory implements event_
|
||||
new std_proxy($dbrow->courseid, $identity),
|
||||
new std_proxy($dbrow->groupid, $identity),
|
||||
new std_proxy($dbrow->userid, $identity),
|
||||
new repeat_event_collection($dbrow->id, $this),
|
||||
new repeat_event_collection($dbrow->id, null, $this),
|
||||
new std_proxy($dbrow->instance, $identity),
|
||||
$dbrow->type,
|
||||
new event_times(
|
||||
|
Loading…
x
Reference in New Issue
Block a user