system/Model.php
protected function trigger(string $event, array $data)
	{
		// Ensure it's a valid event
		if (! isset($this->{$event}) || empty($this->{$event}))
		{
			return $data;
		}

		foreach ($this->{$event} as $callback)
		{
			if (! method_exists($this, $callback))
			{
				throw DataException::forInvalidMethodTriggered($callback);
			}

			$data = $this->{$callback}($data);
		}

		return $data;
	}
protected function trigger(string $event, array $data)
	{
		// Ensure it's a valid event
		if (! isset($this->{$event}) || empty($this->{$event}))
		{
			return $data;
		}

		foreach ($this->{$event} as $callback)
		{
			if (! method_exists($this, $callback))
			{
				throw DataException::forInvalidMethodTriggered($callback);
			}

			$data = $this->{$callback}($data);
		}

		return $data;
	}
A simple event trigger for Model Events that allows additional
data manipulation within the model. Specifically intended for
usage by child models this can be used to format data,
save/load related classes, etc.

It is the responsibility of the callback methods to return
the data itself.

Each $data array MUST have a 'data' key with the relevant
data for callback methods (like an array of key/value pairs to insert
or update, an array of results, etc)

@param string $event
@param array  $data

@return mixed
@throws \CodeIgniter\Database\Exceptions\DataException