onBeforeSync

This handler fires immediately before an item is created or updated that originates from a synced source. (At present, $type may only be ‘events’.) This will let you do things like filter or modify the feed values before they’re imported into LiveWhale. An example module is below.

Parameter Description
$type currently only works for $type = “events”
$subscription_id id of the linked calendar
$buffer array of the feed item values
<?php
     $_LW->REGISTERED_APPS['my_app']=[
       'title'=>'My App',
       'handlers'=>['onBeforeSync'],
    ];

    class LiveWhaleApplicationMyApp {

        // perform additional form validations
        public function onBeforeSync($type, $subscription_id, $buffer) { 
            global $_LW;
                
            if ($type == 'events') {

                // example processing of a feed $buffer:
                if (strpos(@$_LW->linked_calendar_url, '://www.my-athletics-website.com/')!==false) { // if this is an Athletics feed
                    if (stripos($buffer['title'], '(My School) ') === 0) { // remove the first 12 characters if they are "(My School) "
                        $buffer['title'] = substr($buffer['title'], 12);
                    };
                };
                
            }

            return $buffer;
        }
    }
?>