Does global.application.ems_customizations.php still work?

Hello,

I implemented a function in the global.application.ems_customizations.php file a few months ago and it was working up until recently. Here’s the code, it’s just reading the EMS status and if it is “Confirmed” or “Multiple Book” it adds “Open to the Public” to the categories of the buffer.

$_LW->REGISTERED_APPS['ems_customizations']=[
    'title'=>'EMS Customizations',
    'handlers'=>['onBeforeEMSFeed']
]; // configure this module

class LiveWhaleApplicationEmsCustomizations
{

    public function onBeforeEMSFeed($buffer, $booking)
    { 
        
        global $_LW;

        // DEBUG CODE: Refresh an EMS feed and then visit /livewhale/?lw_debug=4 to see the following debug entries:
        $_LW->logDebug('Current buffer = ' . json_encode($buffer) . ' // Current booking = ' . json_encode($booking));
            
        // EXAMPLE:
        // Customize the EMS feed  to use CATEGORIES (e.g. "Open Rec Basketball") as LWC Tags.
        if ($booking->status === "Confirmed" || $booking->status === "Multiple Book") { 
            $buffer['categories'] = 'Open to the Public';
        };
        
        return $buffer;
    }

}

However, when I resync the EMS feed and go into my event “Open to the Public” is not checked.

My LWC version is 2.15.2.

Hi Brandon,

Thanks for writing. Here’s two ideas of things I think could be happening here, which you could try testing on dev:

  1. Event types (categories) only get applied to events when they’re first created from a Linked Calendar. So, in order to test a code change like that, you’ll either want to delete an individual event from LWC first, so the next Refresh of the feed re-creates it entirely. Or, you can use the “Save and reset all events” button from the linked calendar editor to delete and reload all events.

  2. There is some special behavior for “Open to the Public” in LiveWhale core going back a number of years which is that it gets saved to the database with a space before it (" Open to the Public") so it always appears first in alphabetical listings. You could try playing with your code to add a space there, or seeing if you’re able to get it to apply another event type like Academic Calendar, and if so then that might indicate that it’s something to do with the special treatment of Open to the Public.

Hope this helps!

I have figured this out. I was using object notation instead of array notation for targeting properties. Here’s what worked:

$_LW->REGISTERED_APPS['ems_customizations']=[
    'title'=>'EMS Customizations',
    'handlers'=>['onBeforeEMSFeed']
]; // configure this module

class LiveWhaleApplicationEmsCustomizations
{

    public function onBeforeEMSFeed($buffer, $booking)
    { 
        
        global $_LW;

        // DEBUG CODE: Refresh an EMS feed and then visit /livewhale/?lw_debug=4 to see the following debug entries
        // EXAMPLE:
        // Customize the EMS feed  to use CATEGORIES (e.g. "Open Rec Basketball") as LWC Tags.
        if ($booking['status'] === "Confirmed" || $booking['status'] === "Multiple Book") { 
            $buffer['categories'] = $buffer['categories'] . '| Open to the Public';
        }
        
        return $buffer;
    }

}
1 Like

Ah, terrific! Glad you were able to solve it, nice work Brandon. :+1: