Create a class based listener using the IoC container.

@param  mixed    $listener
@return \Closure
977903
public function createClassListener($listener)
	{
		$container = $this->container;

		return function() use ($listener, $container)
		{
			// If the listener has an @ sign, we will assume it is being used to delimit
			// the class name from the handle method name. This allows for handlers
			// to run multiple handler methods in a single class for convenience.
			$segments = explode('@', $listener);

			$method = count($segments) == 2 ? $segments[1] : 'handle';

			$callable = array($container->make($segments[0]), $method);

			// We will make a callable of the listener instance and a method that should
			// be called on that instance, then we will pass in the arguments that we
			// received in this method into this listener class instance's methods.
			$data = func_get_args();

			return call_user_func_array($callable, $data);
		};
	}
1350188
public function addEventListener(callable $listener): void
    {
        /** @var \Jasny\EventDispatcher\EventDispatcher $dispatcher */
        $dispatcher = type_check(
            $this->getEventDispatcher(),
            'Jasny\EventDispatcher\EventDispatcher',
            new LogicException('Unsupported event dispatcher. Please overload the addEventListener method.')
        );

        /** @var \Jasny\EventDispatcher\ListenerProvider $provider */
        $provider = type_check(
            $dispatcher->getListenerProvider(),
            'Jasny\EventDispatcher\ListenerProvider',
            new UnexpectedValueException('Unsupported listener provider; expected %2s, got %1s')
        );

        $newProvider = $provider->withListener($listener);
        $newDispatcher = $dispatcher->withListenerProvider($newProvider);

        $this->setEventDispatcher($newDispatcher);
    }
926293
public static function register($targetClass, $listener)
    {
        if (!is_subclass_of($targetClass, 'Windwalker\Event\DispatcherAwareInterface')) {
            throw new \InvalidArgumentException('Target class should be a DispatcherInterface.');
        }

        $targetClass = strtolower(trim($targetClass, '\\'));

        if (is_string($listener) && class_exists($listener)) {
            $listener = new $listener();
        }

        if (!is_object($listener) || is_callable($listener)) {
            throw new \InvalidArgumentException('Listener is not an object or callable.');
        }

        if (!isset(static::$maps[$targetClass])) {
            static::$maps[$targetClass] = [];
        }

        static::$maps[$targetClass][] = $listener;

        return true;
    }
787194
protected function removeListener(callable $listener) : interfaces\Emitter
    {
        foreach ($this->listeners as $event => $priorityMap) {
            foreach ($priorityMap as $priority => $listeners) {
                if (false !== $key = array_search($listener, $listeners, true)) {
                    unset($this->listeners[$event][$priority][$key], $this->chain[$event]);
                }
            }
        }

        return $this;
    }
263049
protected function createClassCallable($listener)
    {
        list($class, $method) = $this->parseClassCallable($listener);

        if ($this->handlerShouldBeQueued($class)) {
            return $this->createQueuedHandlerCallable($class, $method);
        }

        return [$this->container->make($class), $method];
    }
1087634
protected function storeListener($event, callable $listener)
    {
        if (!isset($this->listeners[$event])) {
            $this->listeners[$event] = [];
        }
        $this->listeners[$event][] = $listener;

        return $this;
    }
1072347
protected function removeListenerFromEvent(callable $listener, string $event) : interfaces\Emitter
    {
        foreach ($this->listeners[$event] as $priority => $listeners) {
            if (false !== $key = array_search($listener, $listeners, true)) {
                unset($this->listeners[$event][$priority][$key], $this->chain[$event]);
            }
        }

        return $this;
    }
378058
protected function findListenerSubscription($listener)
    {
        foreach ($this->subscriptions as $subscription) {
            if ($this->subscriptions->getInfo()[0] === $listener) {
                return $subscription;
            }
        }

        return null;
    }
412011
protected function isListener($listener)/*# : bool */
    {
        // object
        if (is_object($listener) &&
            $listener instanceof EventListenerInterface) {
            return true;
        }

        // static class name
        if (is_string($listener) &&
            is_a(
                $listener,
                '\\Phossa\\Event\\Interfaces\\EventListenerStaticInterface',
                true
            )) {
            return true;
        }

        return false;
    }
477198
public function executeAndRedirect(Listener $listener)
    {
        $this->publisher->connected() && $this->publisher->execute();

        return $listener->publishingHasSucceed();
    }
204786
public function getListener($listener)
    {
        if (isset($this->listeners[$listener])) {
            return $this->listeners[$listener];
        }
        return false;
    }
1214073
public function onAfter($event, callable $listener)
    {
        if ($this->markFilters) {
            $listener = $this->wrap($listener, '*', $this->markFilters);
        }

        $this->root->onAfter($event, $listener);

        return $this;

    }
434770
public function create($listener)
    {
        $model = new Fluent([
            'site' => ['name' => \config('app.name', 'Orchestra Platform')],
        ]);

        $form = $this->presenter->form($model);

        return $listener->createSucceed(\compact('form', 'model'));
    }
646192
protected function _callListener(callable $listener, Event $event)
    {
        $data = $event->getData();

        return $listener($event, ...array_values($data));
    }
136535
public function edit(Listener $listener)
    {
        $user = Auth::user();

        $form = $this->presenter->profile($user, 'orchestra::account');

        $this->fireEvent('form', [$user, $form]);

        return $listener->showProfileChanger(['eloquent' => $user, 'form' => $form]);
    }
1232790
protected function callListenerBindings(Listener $listener, Event $event)
    {
        $binding = $listener->determineEventBinding($event);

        if ($listener->hasBinding($binding)) {
            foreach ($listener->getBindings($binding) as $callback) {
                $resource = $event->getResource();

                call_user_func($callback, $resource, $resource->getPath());
            }
        }

        // If a listener has a binding for anything we'll also spin through
        // them and call each of them.
        if ($listener->hasBinding('*')) {
            foreach ($listener->getBindings('*') as $callback) {
                $resource = $event->getResource();

                call_user_func($callback, $event, $resource, $resource->getPath());
            }
        }
    }
156033
public function onBefore($event, callable $listener)
    {
        $this->checkEvent($event);

        if (!isset($this->beforeListeners[$event])) {
            $this->beforeListeners[$event] = [];
        }
        $this->beforeListeners[$event][] = $listener;

        return $this;
    }