Proxy the addEvent command (to be used as a shortcut)

@param  string $collection Name of the collection to store events
@param  array  $event      Event data to store
@return mixed
164137
public function addEvent($collection, array $event = array())
    {
        $event['event_collection'] = $collection;
        $event['projectId'] = $this->getConfig('projectId');
        $event['writeKey'] = $this->getKeyForWriting();

        $command = parent::getCommand('addEvent', $event);

        return $this->execute($command);
    }
51563
public function emitEvent($event)
    {
        if (array_key_exists($event, $this->listeners)) {
            $arg_list = func_get_args();
            array_shift($arg_list);
            foreach ($this->listeners[$event] as $callback) {
                call_user_func_array($callback, $arg_list);
            }
        }

        return $this;
    }
303896
public function addEvent(IDS_Event $event)
    {
        $this->clear();
        $this->events[$event->getName()] = $event;

        return $this;
    }
232644
public function dispatchUntil($eventName, Event $event)
    {
        // skip dispatching because event is already dispatched
        if ($event->isProcessed()) {
            return $event;
        }

        // skip dispatching because event hasn't listeners
        if (!$this->hasListeners($eventName)) {
            return $event;
        }

        $event->setName($eventName);

        foreach ($this->getListeners($event->getName()) as $listener) {
            if (call_user_func($listener, $event)) {
                $event->setProcessed(true);
                break;
            }
        }

        return $event;
    }
1283861
public function registerCollection(array $collection)
    {
        foreach ($collection as $name => $handler) {
            $this->register($name, $handler);
        }

        return $this;
    }
506072
protected function _proxyEvent($event, $args = array())
    {
        //Publish the event
        if (class_exists('Koowa')) {
            KObjectManager::getInstance()->getObject('event.publisher')->publishEvent($event, $args, JFactory::getApplication());
        }
    }
379588
private function listenTo($event = null) {
        if ($event === null && $this->getEventInvoker()) {
            $event = $this->getEventInvoker()['id'];
        }
        return !$this->listen || in_array($event, $this->listen);
    }
1147922
private function dispatchEvent($event, $args = null)
    {
        return $this->onEventEmitterEnabled(function ($emitter) use($event, $args) {
            return $emitter->emit($event, ! is_array($args) ? [$args] : $args);
        });
    }
782509
protected function registerEventsTo(EntityCollection $collection, $cid)
    {
        $collection->setId($cid);
        $collection->getEmitter()
            ->addListener(
                EntityAdded::ACTION_ADD,
                [$this, 'updateCollection']
            );
        $collection->getEmitter()
            ->addListener(
                EntityRemoved::ACTION_REMOVE,
                [$this, 'updateCollection']
            );
        $entity = $this->repository->getEntityDescriptor()->className();
        Orm::addListener(
            $entity,
            Delete::ACTION_AFTER_DELETE,
            function (Delete $event) use ($collection) {
                $collection->remove($event->getEntity());
            },
            EmitterInterface::P_HIGH
        );
        return $this;
    }
593000
private static function combineEventCollectionArgs(array $args)
    {
        $formattedArgs = array();

        if (isset($args[0]) && is_string($args[0])) {
            $formattedArgs['event_collection'] = $args[0];

            if (isset($args[1]) && is_array($args[1])) {
                $formattedArgs = array_merge($formattedArgs, $args[1]);
            }
        } elseif (isset($args[0]) && is_array($args[0])) {
            $formattedArgs = $args[0];
        }

        return $formattedArgs;
    }
817063
public function add(Event $event)
    {
        $this->doPost('/events/add', $event->toArray());

        /** @var \Fnayou\InstapushPHP\Model\Events $events */
        $events = $this->list();

        return $events->last();
    }
121797
public function afterPrepare(Event $event)
	{
		$command = $event['command'];
		$operation = $command->getOperation();

		if ($command->offsetExists('_kmd')) $command->offsetUnset('_kmd');
		if ($command->offsetExists('_acl')) $command->offsetUnset('_acl');

		if ($operation->getName() !== 'createEntity' && $command->offsetGet('collection') === 'user')
		{
			// These values should never be passed to Kinvey on a user update operation.
			if ($command->offsetExists('username')) $command->offsetUnset('username');
			if ($command->offsetExists('password')) $command->offsetUnset('password');
			if ($command->offsetExists('salt')) $command->offsetUnset('salt');
		}
	}
1139123
public function triggerEvent($event)
	{
		if (!($event instanceof EventInterface))
		{
			if (isset($this->events[$event]))
			{
				$event = $this->events[$event];
			}

			else
			{
				$event = new Event($event);
			}
		}

		if (isset($this->listeners[$event->getName()]))
		{
			foreach ($this->listeners[$event->getName()] as $listener)
			{
				if ($event->isStopped())
				{
					return $event;
				}

				if ($listener instanceof Closure)
				{
					call_user_func($listener, $event);
				}

				else
				{
					call_user_func(array($listener, $event->getName()), $event);
				}
			}
		}

		return $event;
	}
438884
public function beforePrepare(Event $event)
	{
		$command = $event['command'];
		$operation = $command->getOperation();
		$client = $command->getClient();

		if ($command->getName() !== 'updateEntity') return;
		if ($operation->getParam('collection')->getDefault() !== 'user') return;

		// Attempt to get the model's deleted at value from the array of values passed
		// to the command.
		$statusValue = false;

		if ($command->offsetExists(Model::DELETED_AT))
		{
			$statusValue = $command->offsetGet(Model::DELETED_AT);
		}
		elseif ($command->offsetExists('_kmd'))
		{
			$_kmd = array_dot($command->offsetGet('_kmd'));

			$statusField = MODEL::DELETED_AT;
			$statusField = str_replace('_kmd.', '', MODEL::DELETED_AT);

			if (array_key_exists($statusField, $_kmd))
			{
				$statusValue = $_kmd[$statusField];
			}
		}

		// Could not determine the status field.
		if ($statusValue === false)
		{
			return;
		}
		// Suspend the user.
		elseif (!is_null($statusValue))
		{
			$event->stopPropagation();

			$suspendCommand = $client->getCommand('deleteEntity', array(
				'collection' => 'user',
				'_id' => $command->offsetGet('_id'),
			));
			$suspendCommand->execute();
		}
		// Restore.
		else
		{
			$event->stopPropagation();

			$restoreCommand = $client->getCommand('restore', array(
				'_id' => $command->offsetGet('_id'),
			));
			$restoreCommand->execute();
		}
	}
1127058
public function process(array $event)
    {
        $serverData = $this->getServerData();

        /** skip processing if for some reason request data is not present (CLI or wonky SAPIs) */
        /** @noinspection UnSafeIsSetOverArrayInspection */
        if (!isset($serverData['REQUEST_URI'])) {
            return $event;
        }

        $extras = [];

        /** @noinspection UnSafeIsSetOverArrayInspection */
        if (isset($serverData['REQUEST_METHOD'])) {
            $extras['http_method'] = $serverData['REQUEST_METHOD'];
        }

        /** @noinspection UnSafeIsSetOverArrayInspection */
        if (isset($serverData['SERVER_NAME'])) {
            $extras['server'] = $serverData['SERVER_NAME'];
        }

        /** @noinspection UnSafeIsSetOverArrayInspection */
        if (isset($serverData['HTTP_REFERER'])) {
            $extras['referrer'] = $serverData['HTTP_REFERER'];
        }

        /** @noinspection UnSafeIsSetOverArrayInspection */
        if (isset($serverData['REMOTE_ADDR'])) {
            $extras['ip'] = $serverData['REMOTE_ADDR'];
        }

        /** @noinspection SpellCheckingInspection */
        $event['extra'] = array_merge($event['extra'], $extras);

        return $event;
    }
713015
public function dispatchEvent($event, $parameters = array()) {
        if (is_string($event)) {
            $event = new BaseEvent($event, $parameters);
        }
        $eventName = $event->getName();
        $event->setDispatcher($this);
        if ($this->hasListeners($eventName)) {
            foreach($this->_listeners[$eventName] as $priority=>$listeners) {
                foreach($listeners as $listener) {
                    if ($event->isPropagationStopped($priority)) {
                        break;
                    }
                    call_user_func($listener, $event);
                }
            }
        }
        return $event;
    }
348072
public function call($event, array $params = array())
    {

        // Include an instance of this object as the final argument
        $params[] = $this;

        if (isset($this->_hooks[$event])) {
            foreach($this->_hooks[$event] as $hook) {
                call_user_func_array($hook, $params);
            }
        }

        return $this;
    }