civi.afform.searchPaths¶
Summary¶
This Symfony event is dispatched by CRM_Afform_AfformScanner when discovering file-based Afform declarations (*.aff.json and *.aff.html). It allows extensions to register custom search directories or change directory search priority weights.
Definition¶
This event is dispatched via the Symfony EventDispatcher.
public static function onAfformSearchPaths(\Civi\Core\Event\GenericHookEvent $event): void
Parameters¶
\Civi\Core\Event\GenericHookEvent $event
Event Properties¶
Since this event uses GenericHookEvent, properties are accessed dynamically:
$event->paths:array- Reference to list of directory search definitions. Each item contains:path:string- Absolute directory path to search recursively for Afforms.module:string- Extension or module key providing the forms (or empty string for site-local uploads).weight:int- Priority weight (lower weights are scanned earlier; default core weight is 100, local custom forms is 200).
Availability¶
- Available since CiviCRM 5.78
Example¶
use Civi\Core\Event\GenericHookEvent;
public static function onAfformSearchPaths(GenericHookEvent $event): void {
// Register an external forms repository directory
$event->paths[] = [
'weight' => 150,
'path' => '/var/civi/custom_afforms',
'module' => 'org.example.customafforms',
];
}