Hi, So I have an application that displays a list of bookings. These bookings are called from an API and added to a DataObjectSet before being passed to the HTML. The bookings are only displayed if their status is "active".
The DataObjectSet looks like this:
$Res = new DataObjectSet();
foreach($this->Reservations as $current) {
if(!empty($current->Status)) {
if($current->Status == "Active") {
// To retrieve the date in a format that Silverstripe
// will be able to play with, we need to convert it to a date object.
$Date = new Date('Date');
$Date->setValue((string)$current->DateMade);
$dateMade = $Date->Format('D, j M Y');
// Put info from RSS into an Array, then push into $result
$Res->push(new ArrayData(array(
'ItineraryRef' => (int)$current->ItineraryRef,
'Type' => (string)$current->Type,
'DateMade' => (string)$dateMade,
'DateCreated' => (string)$current->DateMade,
'URLDate' => (string)$current->DateMade,
'PaxCount' => (int)$current->PaxCount,
'Description' => (string)$current->Description,
'Status' => (string)$current->Status,
'DateAccessed' => $Date,
)));
$i++;
}
}
Next to each booking is a link which will cancel the booking, again this is done by calling another API that immediately sets the status of the booking to "CANCELLED" so that they do not appear in the list.
I want cancelled bookings to disappear from the list the next time the page refreshes but even though the bookings definitely get cancelled in the back-end; on the front-end, the cancelled bookings always remain 'active' until the user logs off and logs back in again.
I think the problem is that Silverstripe is not calling new data from the API after the page refreshes, it retrieves old data from the DataObjectSet and the information in the DataObjectSet remains intact until the user logs off and the session is destroyed.
So my question is, how do you tell silverstripe to delete any cached information for a specific DataObjectSet or to not cache DataObjects at all?
I tried DataObject::destroy() and $Res->destroy() but that kills the users session too :(
Any alternative ideas are welcome too. Thanks