class MyHooks { /** * Modifies the behavior of the SetContactPhoto function * by adding an additional step to resize the uploaded image. */ public static function myHookSetContactPhoto(&$fileName, &$mimeType, &$imageData) { // Resize the image to a maximum size of 640x480 pixels $imageData = CRM_Core_Image::scale($imageData, 640, 480); } } // Register the hook method with CiviCRM $hook = CRM_Utils_Hook::singleton(); $hook->registerHook('civicrm_contact_set_photo', 1, array('MyHooks', 'myHookSetContactPhoto'));In this example, the "myHookSetContactPhoto" method is registered to listen for the "civicrm_contact_set_photo" event. When this event is triggered, the CRM_Utils_Hook singleton will call this method with the appropriate parameters. Inside the method, we resize the uploaded image before passing it on to the rest of the SetContactPhoto function. Overall, the CRM_Utils_Hook singleton is a powerful tool for developers who need to add custom code to CiviCRM's core functionality. By registering hook methods, you can modify existing behavior or create entirely new features using the event-driven architecture in CiviCRM.