Should the event be ignored (== not logged)?
@param \core\event\base $event
@return bool
191293
protected function is_event_ignored(\core\event\base $event) {
        if ((!CLI_SCRIPT or PHPUNIT_TEST) and !$this->logguests) {
            // Always log inside CLI scripts because we do not login there.
            if (!isloggedin() or isguestuser()) {
                return true;
            }
        }
        return false;
    }
152273
public static function onFlushContent(Event $event)
    {
        $content = $event->getTarget();
        if (!($content instanceof AbstractClassContent)) {
            return;
        }

        $page = $content->getMainNode();
        if (null === $page) {
            return;
        }

        $url = $page->getUrl(false);
        if (!empty($url) && in_array($page->getUid(), self::$alreadyDone)) {
            return false;
        }

        $newEvent = new Event($page);
        $newEvent->setDispatcher($event->getDispatcher());
        self::onFlushPage($newEvent);
    }
771521
public function handleServiceEvent($event)
    {
        Log::debug('Service event handled: ' . $event->name);

        if ($script = $this->getEventScript($event->name)) {
            Log::debug('Service event script found: ' . $event->name);
            $data = $event->makeData();

            if (null !== $result = $this->handleEventScript($script, $data)) {
                return $this->handleEventScriptResult($script, $result);
            }
        } elseif ($script = $this->getEventScript($event->name . '.queued')) {
            Log::debug('Queued service event script found: ' . $event->name);
            $result = $this->dispatchNow(new ServiceEventScriptJob($event->name . '.queued', $event, $script->config));
            Log::debug('Service event queued: ' . $event->name . PHP_EOL . $result);
        }

        return true;
    }
1283784
protected function eventWasProcessed($event)
    {
        if ($this->eventExpired($event)) {
            return true;
        }

        $this->resetEventCache($event);

        return false;
    }
1190695
public function accept(LogEvent $event) : bool
    {
        if (empty($event['origin']['class'])) {
            return false;
        }

        switch ($this->searchMethod) {
            case static::SEARCH_METHOD_STARTS_WITH:
                return (strpos($event['origin']['class'], $this->expectedNamespace) === 0);
            case static::SEARCH_METHOD_CONTAINS:
                $pos = strpos($event['origin']['class'], $this->expectedNamespace);
                if ($pos === false) {
                    return false;
                }

                return ($pos >= 0);
            case static::SEARCH_METHOD_REGEXP:
                return (preg_match($this->expectedNamespace, $event['origin']['class']) > 0);
        }
    // @codeCoverageIgnoreStart
    }
738479
public function hasChildren($event)
    {
        if (!empty($this->getChildrenIds())) {
            $this->owner->message = '删除该数据前请删除或转移其下的子级数据';
            $event->isValid = false;
        }
    }
913138
public function hasListener($event): bool
    {
        $name = $this->getEventName($event);

        if (isset($this->listeners[$name])) {
            foreach ($this->listeners[$name] as $listeners) {
                if (count($listeners) > 0) {
                    return true;
                }
            }
        }

        unset($name);

        return false;
    }
1116227
public function beforeInsert($event = null)
    {
        foreach (['child', 'parent'] as $role) {
            if (!$this->handlePrimary($role)) {
                continue;
            }
            $primaryField = $this->getPrimaryField($role);
            $primarySiblings = $this->getSiblings($role, true);

            $this->wasPrimary[$role] = !empty($this->owner->{$primaryField});
            if (!$this->owner->isActive) {
                $this->owner->{$primaryField} = 0;
            } elseif (empty($primarySiblings)) {
                $this->owner->{$primaryField} = 1;
            }
        }

        return true;
    }
393786
public function off($event)
    {
        if ($this->hasEvent($event)) {
            $handler = $this->eventHandlers[$event];

            unset($this->events[$event], $this->eventHandlers[$event]);

            return $handler;
        }

        return null;
    }
1350244
public static function store(\core\event\base $event) {
        $logmanager = get_log_manager();
        if (get_class($logmanager) === 'tool_log\log\manager') {
            /** @var \tool_log\log\manager $logmanager */
            $logmanager->process($event);
        }
    }
435123
public function isEqual(Event $event)
    {
        try {
            return $this->getName() === $event->getName()
            && $this->get('id') === $event->get('id')
            && self::getSortedKeys($this->getParameters()) === self::getSortedKeys($event->getParameters());
        } catch (\Exception $e) {
        }

        return false;
    }
998897
public function fireEvent($event)
    {
        $handle = $this->getQualifiedEvent($event);

        // Fire the event
        /** @var \League\Event\EventInterface $event */
        $event = $this->explainer->displayBelow(function () use ($handle) {
            return $this->events->emit($handle, [$this]);
        });

        // If the event returned a strict false, halt the task
        $wasHalted = $event && $event->isPropagationStopped();
        if ($wasHalted && $event !== 'halt' && method_exists($this, 'halt')) {
            $this->halt();
        }

        return !$wasHalted;
    }
956985
public static function store(\core\event\base $event) {
        global $DB;

        if (!isloggedin() or \core\session\manager::is_loggedinas() or isguestuser()) {
            // No access tracking.
            return;
        }

        $conditions = [
            'userid' => $event->userid
        ];

        $records = $DB->get_records(self::$table, $conditions, "timeaccess DESC");

        foreach ($records as $record) {
            if (($record->userid == $event->userid) && ($record->cmid == $event->contextinstanceid)) {
                $conditions = [
                        'userid' => $event->userid,
                        'cmid' => $event->contextinstanceid
                ];
                $DB->set_field(self::$table, 'timeaccess', $event->timecreated, $conditions);
                return;
            }
        }

        if (count($records) >= 9) {
            $conditions = [
                    'id' => end($records)->id,
            ];
            $DB->delete_records(self::$table, $conditions);
        }

        $eventdata = new \stdClass();

        $eventdata->cmid = $event->contextinstanceid;
        $eventdata->timeaccess = $event->timecreated;
        $eventdata->courseid = $event->courseid;
        $eventdata->userid = $event->userid;

        $DB->insert_record(self::$table, $eventdata);
    }
1251629
private function onEvent($event)
    {
        if (isset($this->_options[$event])) {
            $onEvent = strtoupper($this->_options[$event]);

            if (! in_array($onEvent, ['NO ACTION', 'RESTRICT'])) {
                return $onEvent;
            }
        }

        return false;
    }
70339
public function onLogEvent(LogEvent $event)
    {
        $context = $event->getContext();
        $context['event.name'] = $event->getEventNameContext();

        $eventSubscriberClassName = get_class($event->getEventSubscriberContext());
        if (strrpos($eventSubscriberClassName, '\\') !== false) {
            $eventSubscriberClassName = substr($eventSubscriberClassName, strrpos($eventSubscriberClassName, '\\') + 1);
        }
        $context['event.task.name'] = $eventSubscriberClassName;

        $this->logger->log($event->getLevel(), $event->getMessage(), $context);
    }
1158776
public function hasEvent($event) {
		return (bool) check_entity_relationship($event->guid, self::EVENT_CALENDAR_RELATIONSHIP, $this->guid);
	}
70123
public function has_events($event)
	{
		if (isset($this->_events[$event]) and count($this->_events[$event]) > 0)
		{
			return true;
		}
		return false;
	}