4.5.3 upgrade.

- setting triggerInvoiceSendEvent removed.
- setting triggerInvoiceEvent introduced.

@return bool
517320
protected function upgrade453()
    {
        // Keep track of settings that should be updated.
        $newSettings = array();
        if ($this->get('triggerInvoiceSendEvent') == 2) {
            $newSettings['triggerInvoiceEvent'] = PluginConfig::TriggerInvoiceEvent_Create;
        } else {
            $newSettings['triggerInvoiceEvent'] = PluginConfig::TriggerInvoiceEvent_None;
        }

        return $this->save($newSettings);
    }
1159355
@Override
    public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
        if (evt instanceof HttpServerUpgradeHandler.UpgradeEvent) {
            HttpServerUpgradeHandler.UpgradeEvent upgradeEvent =
                    (HttpServerUpgradeHandler.UpgradeEvent) evt;
            onHeadersRead(ctx, 1, http1HeadersToHttp2Headers(upgradeEvent.upgradeRequest()), 0 , true);
        }
        super.userEventTriggered(ctx, evt);
    }
1045805
protected function flowEnd()
    {
        $this->flowMap->flowEnd();
        $eventName = FlowEvent::FLOW_SUCCESS;
        $node      = null;
        if ($this->flowStatus->isException()) {
            $eventName = FlowEvent::FLOW_FAIL;
            $node      = $this->nodes[$this->nodeIdx];
        }

        // restore nodeIdx
        $this->nodeIdx = $this->lastIdx + 1;
        $this->triggerEvent($eventName, $node);

        return $this;
    }
639798
public function detectChanges()
    {
        $events = parent::detectChanges();

        // When a descendant file is created or deleted a modified event is fired on the
        // directory. This is the only way a directory will receive a modified event and
        // will thus result in two events being fired for a single descendant modification
        // within the directory. This will clear the events if we got a modified event.
        if (! empty($events) && $events[0]->getCode() == Event::RESOURCE_MODIFIED) {
            $events = [];
        }

        foreach ($this->descendants as $key => $descendant) {
            $descendantEvents = $descendant->detectChanges();

            foreach ($descendantEvents as $event) {
                if ($event instanceof Event && $event->getCode() == Event::RESOURCE_DELETED) {
                    unset($this->descendants[$key]);
                }
            }

            $events = array_merge($events, $descendantEvents);
        }

        // If this directory still exists we'll check the directories descendants again for any
        // new descendants.
        if ($this->exists) {
            foreach ($this->detectDirectoryDescendants() as $key => $descendant) {
                if (! isset($this->descendants[$key])) {
                    $this->descendants[$key] = $descendant;

                    $events[] = new Event($descendant, Event::RESOURCE_CREATED);
                }
            }
        }

        return $events;
    }
1252026
public function Upgrade184to185()
    {
        $this->_batch->addTask('Db_CreateNewTables');
        $this->_batch->addTask('Db_AddPatches', 63);

        // Use AddTask task to execute after patches
        $this->_batch->addTask('AddTask', 'Echo', $this->_('Make sure to read the changelog as it contains important instructions'));
        $this->_batch->addTask('AddTask', 'Echo', $this->_('Check the Code compatibility report for any issues with project specific code!'));

        return true;
    }
873354
protected function isDispatched()/*# : bool */
    {
        $param = ['result' => $this->result];
        if ($this->trigger(self::EVENT_BEFORE_DISPATCH, $param) &&
            $this->executeHandler() &&
            $this->trigger(self::EVENT_AFTER_DISPATCH, $param)
        ) {
            return true;
        }
        return false;
    }
740287
public function updateEventMessage($eventName, $fields) {
        $items = $this->getEventMessages($eventName);

        foreach ($items as $item) {
            $this->updateEventMessageById($item["ID"], $fields);
        }

        return true;
    }
192737
public function unRegisterEvents()
    {
        if (is_array($this->events()) && count($this->events()))
        {
            $event = new Event($this);
            return $event->remove();
        }
        return true;
    }
1338176
public function registerEvents()
    {
        if (is_array($this->events()) && count($this->events()))
        {
            $event = new Event($this);
            return $event->add();
        }
        return true;
    }
967187
public function beforeModeration(): bool
    {
        if (method_exists($this->owner, 'beforeModeration')) {
            if (!$this->owner->beforeModeration()) {
                return false;
            }
        }

        $event = new ModelEvent();
        $this->owner->trigger(self::EVENT_BEFORE_MODERATION, $event);

        return $event->isValid;
    }
329892
public static function initEvent()
    {
        if (!self::$supported) {
            return;
        }
        self::updateConfig();
        self::$fd = eio_get_event_stream();
        self::$ev = EventLoop::$instance->event(self::$fd,
            \Event::READ | \Event::PERSIST,
            function ($fd, $events, $arg) {
                while (eio_nreqs()) {
                    eio_poll();
                }
            }
        );
        self::$ev->add();
    }
1277718
protected function setTitleEditTrigger()
    {
        if (isset($this->data_trigger['name'])) {
            $title = $this->text('Edit %name', array('%name' => $this->data_trigger['name']));
        } else {
            $title = $this->text('Add trigger');
        }

        $this->setTitle($title);
    }
612700
public static function onPreUpdate(Event $event)
    {
        $page = $event->getTarget();
        $eventArgs = $event->getEventArgs();

        if ($eventArgs instanceof PreUpdateEventArgs) {
            if ($eventArgs->hasChangedField('_workflow_state')) {
                $old = $eventArgs->getOldValue('_workflow_state');
                $new = $eventArgs->getNewValue('_workflow_state');

                if (null !== $new && null !== $listener = $new->getListenerInstance()) {
                    $listener->switchOnState($event);
                }

                if (null !== $old && null !== $listener = $old->getListenerInstance()) {
                    $listener->switchOffState($event);
                }
            }

            if ($eventArgs->hasChangedField('_state')) {
                if (
                    !($eventArgs->getOldValue('_state') & Page::STATE_ONLINE)
                    && $eventArgs->getNewValue('_state') & Page::STATE_ONLINE
                ) {
                    $event->getDispatcher()->triggerEvent('putonline', $page);
                } elseif (
                    $eventArgs->getOldValue('_state') & Page::STATE_ONLINE
                    && !($eventArgs->getNewValue('_state') & Page::STATE_ONLINE)
                ) {
                    $event->getDispatcher()->triggerEvent('putoffline', $page);
                }
            }
        }
    }
577623
public function Upgrade155to156()
    {
        $this->_batch->addTask('Db_AddPatches', 49);

        $this->_batch->addTask('Echo', $this->_('Make sure to read the changelog as it contains important instructions'));

        return true;
    }
1128563
protected function trigger()
    {
        $eventName = $this->getParameter('name');

        if(StringUtils::strToBool($this->getParameter('allowTemplateCode')) == true)
            $this->allowTemplateCode();

        $params = $this->getParameters();

        $output = new Transport();
        $output->String = '';

        foreach($params as $k => $v) {
            if($k != 'String' && $k !='name') {
                $output->$k = $v;
            }
        }

        $this->Events->trigger($eventName, $output);

        return $output->String;
    }
865516
public function eventAdd()
    {
        $this->notEventAdd = false;
        swoole_event_add($this->process->pipe, [$this, 'getPipeMessage']);

        return $this;
    }
1193756
public function Upgrade171to172()
    {
        $this->_batch->addTask('Db_CreateNewTables');
        $this->_batch->addTask('Db_AddPatches', 58);

        $this->_batch->addTask('Echo', $this->_('Make sure to read the changelog as it contains important instructions'));
        $this->_batch->addTask('Echo', $this->_('Check the Code compatibility report for any issues with project specific code!'));

        return true;
    }