Get Event Types from Configure::read()

@param string $name of the event type

@return mixed[] $result containing key/value pair of event types.
15394
public function getEventTypeBy(? string $name = null): array
    {
        $result = [];
        $configs = Configure::read('Calendar.Types');

        if (empty($configs)) {
            return $result;
        }

        if (!empty($name)) {
            $configs = array_filter($configs, function ($item) use ($name) {
                if ($name == $item['value']) {
                    return $item;
                }
            });
        }

        $configs = array_values($configs);

        foreach ($configs as $k => $calendar) {
            if (empty($calendar['calendar_events'])) {
                continue;
            }

            foreach ($calendar['calendar_events'] as $type => $properties) {
                $value = $this->getEventTypeName([
                    'name' => $calendar['name'],
                    'type' => $type,
                ]);

                $result[$value] = $value;
            }
        }

        asort($result);

        return $result;
    }
438069
private function fetchItems($name)
    {

        $event = new Event("Navigator.{$name}", $this, []);
        $this->eventManager()->dispatch($event);
        
        return $event->data;
    }
173772
public function config_read($name) {
        global $CFG;
        if (!empty($this->plugin)) {
            $value = get_config($this->plugin, $name);
            return $value === false ? NULL : $value;

        } else {
            if (isset($CFG->$name)) {
                return $CFG->$name;
            } else {
                return NULL;
            }
        }
    }
957739
public function getResult($name=NULL) {
		$result = NULL;
		if(isset($this->payload['result'])) {
			$result = $this->payload['result'];
		} else {
			return NULL;
		}

		if(isset($name)) {
			if(isset($result[$name])) {
				return $result[$name];
			}
		} else {
			return $result;
		}
	}
1098104
public function getStatus($name = '') {
        if ($name != '') {
            if (isset($this->_events[$name])) {
                return $this->_events[$name]->getStatus();
            }
            else {
                return false;
            }
        }
        else {
            return false;
        }
    }
956799
static function GetArray($name = null)
    {
        $get = filter_input_array(INPUT_GET);
        if (!$name)
        {
            return $get === null ? array() : $get;
        }
        else if (isset($get[$name]) && is_array($get[$name]))
        {
            return $get[$name];
        }
        return array();
    }
94211
public function getListners($name)
    {
        if (! $this->hasListener($name)) return [];

        $listeners = [];
        krsort($this->listeners[$name]);
        foreach ($this->listeners[$name] as $_listeners) {
            $listeners = array_merge($listeners, $_listeners);
        }

        return $listeners;
    }
1225398
public function get($name)
    {
        $this->eventDispatcher->dispatch(Events::PRE_GET, new SettingActionEvent($name, [], null));

        /** @var Setting $setting */
        $setting = $this->repo->findOneBy(['name.name' => $name]);

        $this->eventDispatcher->dispatch(Events::PRE_GET, new SettingActionEvent($name, [], $setting));

        return $setting;
    }
301777
public function listeners($event_name)
    {
        // Read in our config/events file so that we have them all!
        if (! $this->have_read_from_file)
        {
            $this->readConfigFile();
        }

        if (! isset($this->listeners[$event_name]))
        {
            return [];
        }

        // The list is not sorted
        if (! $this->listeners[$event_name][0])
        {
            // Sort it!
            array_multisort($this->listeners[$event_name][1], SORT_NUMERIC, $this->listeners[$event_name][2]);

            // Mark it as sorted already!
            $this->listeners[$event_name][0] = true;
        }

        return $this->listeners[$event_name][2];
    }
54970
public function getListeners($name)
    {
        $listenerMatched = false;

        /**
         * Do we have an exact match?
         */
        if (isset($this->queues[$name])) {
            $listenerMatched = true;
        }

        /**
         * Optionally search for wildcard matches.
         */
        if ($this->wildcardSearching) {
            if ($this->populateQueueFromWildSearch($name)) {
                $listenerMatched = true;
            }
        }

        $listeners = [];
        if ($listenerMatched) {
            foreach ($this->queues[$name] as $key) {
                $listeners[] = $this->callbacks[$key];
            }
        }

        return $listeners;
    }
188230
public function parse($name)
    {
        $segments = array_reverse(explode('_', $name));

        if ($segments[0] == 'table') {
            array_shift($segments);
        }

        return [
            'action' => $this->getAction($segments),
            'table' => $this->getTableName($segments)
        ];
    }
984382
protected function loadTypeExtensions($name)
    {
        $typeExtensions = [];

        $extensions = $this->getExtensions();
        foreach ($extensions as $extension) {
            if ($extension->hasTypeExtensions($name)) {
                $typeExtensions = array_merge($typeExtensions, $extension->getTypeExtensions($name));
            }
        }
        $this->typeExtensions[$name] = $typeExtensions;

        return $typeExtensions;
    }
162182
public function dispatchEvent($name, $event = array())
    {
        $result = array();
        
        //Make sure we have an event object
        if (! $event instanceof AnEvent) {
            $event = new AnEvent($event);
        }
        
        $event->setName($name)->setDispatcher($this);
             
        //Nofity the listeners
        if (isset($this->_listeners[$name])) {
            foreach ($this->_listeners[$name] as $listener) {
                $listener->$name($event);
                
                if (! $event->canPropagate()) {
                    break;
                }
            }
        }
        
        return $this;
    }
642851
public function getEventScript($name)
    {
        $cacheKey = Cache::EVENT_SCRIPT_CACHE_PREFIX . $name;
        try {
            /** @var EventScript $model */
            $model = \Cache::rememberForever($cacheKey, function () use ($name) {
                if ($model = EventScript::whereName($name)->whereIsActive(true)->first()) {
                    if (!empty($model->storage_service_id) && !empty($model->storage_path)) {
                        try {
                            $serviceId = $model->storage_service_id;
                            $service = \ServiceManager::getServiceById($serviceId);
                            $storagePath = trim($model->storage_path, '/');
                            $scmRepo = $model->scm_repository;
                            $scmRef = $model->scm_reference;
                            if (empty($scmRef)) {
                                $scmRef = null;
                            }
                            $serviceName = $service->getName();
                            $typeGroup = $service->getServiceTypeInfo()->getGroup();

                            if ($typeGroup === ServiceTypeGroups::SCM) {
                                $result = \ServiceManager::handleRequest(
                                    $serviceName,
                                    Verbs::GET,
                                    '_repo/' . $scmRepo,
                                    ['path' => $storagePath, 'branch' => $scmRef, 'content' => 1]
                                );
                                $model->content = $result->getContent();
                            } else {
                                $result = \ServiceManager::handleRequest(
                                    $serviceName,
                                    Verbs::GET,
                                    $storagePath,
                                    ['include_properties' => 1, 'content' => 1]
                                );

                                $model->content = base64_decode(array_get($result->getContent(), 'content'));
                            }
                        } catch (\Exception $e) {
                            \Log::error('Failed to fetch remote script. ' . $e->getMessage());
                            throw $e;
                        }
                    }

                    return $model;
                }

                return ''; // so that we don't hit the database even after we know it isn't there
            });

            if (!empty($model)) { // see '' returned above
                return $model;
            }
        } catch (\Exception $ex) {
            \Log::error('Error occurred while loading event script. ' . $ex->getMessage());
        }

        return null;
    }
669644
private function getTriggerCallbacks($name)
    {
        if(!isset($this->events[$name]))
        {
            $this->events[$name] = new KVStorage;
        }
        if(!isset($this->eventQueue[$name]))
        {
            $this->rebuildEventQueue($name);
            $data = ClassEventParser::getInstance()->getData();
            foreach($data as $className => $option)
            {
                if($this instanceof $className && isset($option[$name]))
                {
                    foreach($option[$name] as $callback)
                    {
                        // 数据映射
                        $this->events[$name]->attach($callback['className'], [
                            'callback' => $callback['className'],
                            'priority' => $callback['priority'],
                        ]);
                        $this->eventQueue[$name]->insert($callback['className'], $callback['priority']);
                    }
                }
            }
        }
        else if(isset($this->eventChangeRecords[$name]))
        {
            $this->rebuildEventQueue($name);
        }
        $callbacks = clone $this->eventQueue[$name];
        return $callbacks;
    }
623154
public function get($name, $default = null)
    {
        try {
            if ($setting = $this->model->where('name', '=', $name)->first()) {
                return $this->castSetting($name, $setting->value);
            }

            return $default;
        } catch (Exception $e) {
            throw new ReadException($e);
        }
    }
548779
public function inferDatatype($name) {
		foreach($this->config()->infer_datatype as $match => $type) {
			if(strstr($name, $match) !== false) {
				return $type;
			}
		}

		return $this->config()->default_datatype;
	}