3 namespace Civi\Api4\Event
;
5 trait ActiveUserTrait
{
8 * Contact ID of the active/target user (whose access we must check).
16 * @param int|null $userID
17 * Contact ID of the active/target user (whose access we must check).
21 protected function setUser(int $userID) {
22 $loggedInContactID = \CRM_Core_Session
::getLoggedInContactID() ?
: 0;
23 if ($userID !== $loggedInContactID) {
24 throw new \
RuntimeException("The API subsystem does not yet fully support variable user IDs.");
25 // Traditionally, the API events did not emit information about the current user; it was assumed
26 // that the user was the logged-in user. This may be expanded in the future to support some more edge-cases.
27 // For now, the semantics are unchanged - but we've begun reporting the active userID so that
28 // consumers can start adopting it.
30 $this->userID
= $userID;
36 * Contact ID of the active/target user (whose access we must check).
39 public function getUserID(): int {