Skip to main content
Skip table of contents

Triggering Events

attachDb / attach

Attaches all Event Listeners for the specified event name. attachDb is used when adding events to the database. attach is used when triggering events immediately.

PHP
PCR_Event::attachDb(string $event, array $listeners)
PCR_Event::attach(string $event, array $listeners)

Parameters

$event: The event identifier. A unique identifier for this event trigger

$listeners: An array for key-value pairs. Listener Class as the Key and Listener Function as the value.

trigger

PHP
PCR_Event::trigger(string $event, array $listeners)

Parameters

$event: The event identifier. A unique identifier for this event trigger

$listeners: An array of key-value pairs. Listener Class as the Key and Listener Function as the value.

detachDb / detach

Detaches all Event Listeners for the specified event name. detachDb is used when adding events to the database. detach is used when triggering events immediately.

PHP
PCR_Event::detachDb(string $event, array $listeners)
PCR_Event::detach(string $event, array $listeners)

Parameters

$event: The event identifier. A unique identifier for this event trigger

$listeners: An array of key-value pairs. Listener Class as the key and Listener Function as value. Removes the Event Listener from the Event system. Only needed if the process is going to continue to trigger other events.

Example: Triggering a GLA Relace

In this example the GLA Replace Event is triggered with specific parameters. For detailed information on which Events can be triggered, and how to trigger those Events, please navigate to the Triggerable Events List page.

CODE
PCR_Event::attachDb("replace-gla", [
    "Application_Model_Gla_Gla" => "eventReplaceGla"
]);
PCR_Event::trigger("replace-gla", [
	"contact" => 12345,        // Contact RECID
    "users_recid" => 456,      // Users RECID
    "glaRecid" => [1111],      // Old GLA RECID
    "replaceGlaRecid" => 2222, // Replacement GLA RECID
    "setInactiveGla" => true,
    "comment" => "This is a comment",
]);
PCR_Event::detachDb("replace-gla",
    ["Application_Model_Gla_Gla" => "eventReplaceGla"]
);
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.