Elgg\Notifications\Event::__construct PHP Method

__construct() public method

Create a notification event
public __construct ( ElggDat\ElggData $object, string $action, ElggEntit\ElggEntity $actor = null )
$object ElggDat\ElggData The object of the event (ElggEntity)
$action string The name of the action (default: create)
$actor ElggEntit\ElggEntity The entity that caused the event (default: logged in user)
    public function __construct(ElggData $object, $action, ElggEntity $actor = null)
    {
        if (get_class($this) == Event::class || get_class($this) == Elgg_Notifications_Event::class) {
            _elgg_services()->deprecation->sendNotice(__CLASS__ . ' is deprecated. ' . 'Use ' . SubscriptionNotificationEvent::class . ' instead', '2.3');
        }
        if (!$object instanceof ElggData) {
            throw new InvalidArgumentException(__METHOD__ . ' expects an object as an instance of ' . ElggData::class);
        }
        if (!$action) {
            throw new InvalidArgumentException(__METHOD__ . ' expects a valid action name');
        }
        $this->object = $object;
        $this->actor = $actor;
        if (!isset($actor)) {
            $this->actor = _elgg_services()->session->getLoggedInUser();
        }
        $this->action = $action;
    }