core/Event/EventManager.php
public static function dispatcher($name)
	{
		static $all = [];

		if(! isset($all[$name]))
		{
			// system has been installed
			// use default mode
			if(Helper::isSystemInstall())
			{
				$cache = new Cache($name, 'events');

				if( $cache->ready() )
				{
					$data = $cache->import();
				}
				else
				{
					$event = new EventFactory($name);
					if( $event->load() === false )
					{
						throw new NotFoundException("Event '{$name}' is not registered in system");
					}

					$data = $event->getContentData();
					if(! $cache->export($data))
					{
						throw new WriteException("Can't write cache data for the '{$name}' event");
					}
				}
			}
			else
			{
				$data = (new EventFactory($name))->getContentData();
			}

			$manager = new Dispatcher(
				$data["name"],
				$data["completable"],
				function (Dispatcher $manager) use ($data) {
					foreach($data["classes"] as $class_name)
					{
						/** @var \EApp\Event\Interfaces\EventPrepareInterface $class */
						$class = new $class_name($data["name"]);
						$class->prepare($manager);
					}
				});

			$all[$name] = $manager;
		}

		return $all[$name];
	}
public static function dispatcher($name)
	{
		static $all = [];

		if(! isset($all[$name]))
		{
			// system has been installed
			// use default mode
			if(Helper::isSystemInstall())
			{
				$cache = new Cache($name, 'events');

				if( $cache->ready() )
				{
					$data = $cache->import();
				}
				else
				{
					$event = new EventFactory($name);
					if( $event->load() === false )
					{
						throw new NotFoundException("Event '{$name}' is not registered in system");
					}

					$data = $event->getContentData();
					if(! $cache->export($data))
					{
						throw new WriteException("Can't write cache data for the '{$name}' event");
					}
				}
			}
			else
			{
				$data = (new EventFactory($name))->getContentData();
			}

			$manager = new Dispatcher(
				$data["name"],
				$data["completable"],
				function (Dispatcher $manager) use ($data) {
					foreach($data["classes"] as $class_name)
					{
						/** @var \EApp\Event\Interfaces\EventPrepareInterface $class */
						$class = new $class_name($data["name"]);
						$class->prepare($manager);
					}
				});

			$all[$name] = $manager;
		}

		return $all[$name];
	}
public static function dispatcher ( $ name ) { static $ all = [ ] ; if ( ! isset ( $ all [ $ name ] ) ) { // system has been installed // use default mode if ( Helper :: isSystemInstall ( ) ) { $ cache = new Cache ( $ name , 'events' ) ; if ( $ cache -> ready ( ) ) { $ data = $ cache -> import ( ) ; } else { $ event = new EventFactory ( $ name ) ; if ( $ event -> load ( ) === false ) { throw new NotFoundException ( "Event '{$name}' is not registered in system" ) ; } $ data = $ event -> getContentData ( ) ; if ( ! $ cache -> export ( $ data ) ) { throw new WriteException ( "Can't write cache data for the '{$name}' event" ) ; } } } else { $ data = ( new EventFactory ( $ name ) ) -> getContentData ( ) ; } $ manager = new Dispatcher ( $ data [ "name" ] , $ data [ "completable" ] , function ( Dispatcher $ manager ) use ( $ data ) { foreach ( $ data [ "classes" ] as $ class_name ) { /** @var \EApp\Event\Interfaces\EventPrepareInterface $class */ $ class = new $ class_name ( $ data [ "name" ] ) ; $ class -> prepare ( $ manager ) ; } } ) ; $ all [ $ name ] = $ manager ; } return $ all [ $ name ] ; }
Get event manager element from cache

@param $name
@return \EApp\Event\Dispatcher
@throws \Exception
Get event manager element from cache