Skip to content

Commit

Permalink
remove eventid from schedule event resource when the schedule event i…
Browse files Browse the repository at this point in the history
…s deleted
  • Loading branch information
noam-arad committed Apr 2, 2017
1 parent f8a961f commit a2fd288
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions plugins/schedule/base/lib/kScheduleEventsConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public function shouldConsumeChangedEvent(BaseObject $object, array $modifiedCol
if ($object instanceof categoryEntry && in_array(categoryEntryPeer::STATUS, $modifiedColumns) && $object->getStatus() == CategoryEntryStatus::ACTIVE)
return true;

if ($object instanceof ScheduleEvent && in_array(ScheduleEventPeer::STATUS, $modifiedColumns) && $object->getStatus() == ScheduleEventStatus::DELETED)
return true;

return false;
}

Expand All @@ -42,6 +45,8 @@ public function objectChanged(BaseObject $object, array $modifiedColumns)
{
if ($object instanceof categoryEntry)
$this->reindexScheduleEvents($object->getEntryId());
if ($object instanceof ScheduleEvent)
$this->scheduleEventChanged($object, $modifiedColumns);

return true;
}
Expand Down Expand Up @@ -115,4 +120,17 @@ public function updateScheduleEvent($eventId)
}
}

protected function scheduleEventChanged(ScheduleEvent $scheduleEvent, $modifiedColumns)
{
$scheduleEvents = ScheduleEventResourcePeer::retrieveByEventId($scheduleEvent->getId());
foreach ($scheduleEvents as $currScheduleEvent)
{
/**
* @var ScheduleEventResource $currScheduleEvent
*/
$currScheduleEvent->setEventId(null);
$currScheduleEvent->save();
}
}

}

0 comments on commit a2fd288

Please sign in to comment.