I'm trying to write a wrapper function in a page class to get the most recent Calendar page, then call the Events() function on that since Calendar.php has an Events function. I tried the following:
$cal = DataObject::get("Calendar", "", "Created DESC", "", 1);
I get the error:
[User Error] Uncaught Exception: Object->__call(): the method 'events' does not exist on 'DataObjectSet'
I assume it's because DataObject::get returns a DataObjectSet that contains the Calendar object in it. If that's the case, how do I get the Calendar object from that where I can call its Events() method? If I'm wrong, how would I go about accomplishing what I'm trying to do?
Thanks for any help.