@param HTMLHandlerInterface $handler
@param DOMElement           $container
@param array                $values

@throws \InvalidArgumentException
@throws \Exception
191065
public static function setValues(HTMLHandlerInterface $handler, DOMElement $container, $values = [])
    {
        foreach ($values as $name => $value) {
            // Normal inputs
            $types = ['text', 'number', 'email', 'hidden', 'password'];
            foreach ($types as $type) {
                $input = self::getElementBySelector($handler, $container, sprintf('input[type="%s"][name="%s"]', $type, $name));
                if (!empty($input)) {
                    $handler->attr($input, 'value', $value);
                }
            }

            // Checkbox
            $types = ['checkbox'];
            foreach ($types as $type) {
                $input = self::getElementBySelector($handler, $container, sprintf('input[type="%s"][name="%s"]', $type, $name));
                if (!empty($input)) {
                    $handler->attr($input, 'checked', $value);
                }
            }

            // Radio
            $types = ['radio'];
            foreach ($types as $type) {
                $input = self::getElementBySelector($handler, $container, sprintf('input[type="%s"][name="%s"][value="%s"]', $type, $name, $value));
                if (!empty($input)) {
                    $handler->attr($input, 'checked', $value);
                }
            }

            // Options in select
            $option = self::getElementBySelector($handler, $container, sprintf('select[name="%s"] option[value="%s"]', $name, $value));
            if (!empty($option)) {
                $handler->attr($option, 'selected', true);
            }

            // Textareas
            $textarea = self::getElementBySelector($handler, $container, sprintf('textarea[name="%s"]', $name));
            if (!empty($textarea)) {
                $handler->innerHTML($textarea, $value);
            }
        }
    }
517647
public function handle(Event $event)
    {
        // Define Event:
        
        $this->setEvent($event);
        
        // Check Event Name:
        
        if (!$this->hasHandler($event->getName())) {
            
            throw new InvalidArgumentException(
                sprintf(
                    'An event handler does not exist for "%s"',
                    $event->getName()
                )
            );
            
        }
        
        // Handle Event:
        
        $this->{$this->handlers[$event->getName()]}();
    }
182053
protected function prepareHandler(HandlerInterface $handler, array $config = [])
    {
        if (! isset($config['formatter'])) {
            $handler->setFormatter($this->formatter());
        } elseif ($config['formatter'] !== 'default') {
            $handler->setFormatter($this->app->make($config['formatter'], $config['formatter_with'] ?? []));
        }

        return $handler;
    }
799741
private static function invalidRequestHandler(ContainerInterface $container): InvalidRequestHandlerInterface
    {
        if (!$container->has(InvalidRequestHandlerInterface::class)) {
            return new InvalidRequestHandler();
        }

        return $container->get(InvalidRequestHandlerInterface::class);
    }
772233
public function handle(EventListenerInterface $listener)
    {
        if (!$listener->getListeners()) {
            return;
        }

        $content = $this->request->getContent();

        try {
            $options = Serializer::parse($content);
        } catch (\InvalidArgumentException $e) {
            $options = [];
        }

        foreach ($listener->getListeners() as $namespace => $callable) {
            $event = new $namespace($options);
            if ($event->isValid()) {
                $listener->trigger($namespace, $event);
                break;
            }
        }
    }
344855
public function registerEventHandler($event, callable $handler)
    {
        if (empty($event)) {
            throw new InvalidArgumentException('Event name is required');
        }

        if (is_callable($handler)) {
            if (empty($this->event_handlers[$event])) {
                $this->event_handlers[$event] = [];
            }

            $this->event_handlers[$event][] = $handler;
        } else {
            throw new InvalidArgumentException('Handler not callable');
        }
    }
1234229
public static function insert( $table, $values = array(), $handler = null )
	{
		return Query_Insert::create( $table, $handler )->values( $values );
	}
500109
public function runAjaxHandler($handler)
    {
        /**
         * @event cms.component.beforeRunAjaxHandler
         * Provides an opportunity to modify an AJAX request to a component before it is processed by the component
         *
         * The parameter provided is `$handler` (the requested AJAX handler to be run)
         *
         * Example usage (forwards AJAX handlers to a backend widget):
         *
         *     Event::listen('cms.component.beforeRunAjaxHandler', function((\Cms\Classes\ComponentBase) $component, (string) $handler) {
         *         if (strpos($handler, '::')) {
         *             list($componentAlias, $handlerName) = explode('::', $handler);
         *             if ($componentAlias === $this->getBackendWidgetAlias()) {
         *                 return $this->backendControllerProxy->runAjaxHandler($handler);
         *             }
         *         }
         *     });
         *
         * Or
         *
         *     $this->controller->bindEvent('component.beforeRunAjaxHandler', function ((string) $handler) {
         *         if (strpos($handler, '::')) {
         *             list($componentAlias, $handlerName) = explode('::', $handler);
         *             if ($componentAlias === $this->getBackendWidgetAlias()) {
         *                 return $this->backendControllerProxy->runAjaxHandler($handler);
         *             }
         *         }
         *     });
         *
         */
        if ($event = $this->fireSystemEvent('cms.component.beforeRunAjaxHandler', [$handler])) {
            return $event;
        }

        $result = $this->$handler();

        /**
         * @event cms.component.runAjaxHandler
         * Provides an opportunity to modify an AJAX request to a component after it is processed by the component
         *
         * The parameters provided are `$handler` (the requested AJAX handler to be run) and `$result` (the result of the component processing the request)
         *
         * Example usage (Logs requests and their response):
         *
         *     Event::listen('cms.component.beforeRunHandler', function((\Cms\Classes\ComponentBase) $component, (string) $handler, (mixed) $result) {
         *         if (in_array($handler, $interceptHandlers)) {
         *             return 'request has been intercepted, original response: ' . json_encode($result);
         *         }
         *     });
         *
         * Or
         *
         *     $this->controller->bindEvent('componenet.beforeRunAjaxHandler', function ((string) $handler, (mixed) $result) {
         *         if (in_array($handler, $interceptHandlers)) {
         *             return 'request has been intercepted, original response: ' . json_encode($result);
         *         }
         *     });
         *
         */
        if ($event = $this->fireSystemEvent('cms.component.runAjaxHandler', [$handler, $result])) {
            return $event;
        }

        return $result;
    }
641342
public void addHandler(Handler handler) {
        if (null == handlers) {
            handlers = new ArrayList<>();
        }
        handlers.add(handler);
    }
213593
public static function create($handler, $xml)
    {
        switch ($handler) {
            case 'Search':
                return new SearchResponseHandler($xml);
            case 'FullSearch':
                return new FullSearchResponseHandler($xml);
            case 'ShowInfo':
                return new ShowInfoResponseHandler($xml);
            case 'EpisodeList':
                return new EpisodeListResponseHandler($xml);
            case 'EpisodeInfo':
                return new EpisodeInfoResponseHandler($xml);
            default:
                throw new InvalidHandlerException('Unknown handler ' . $handler);
        }
    }
110033
public function suscribe($events, Closure $handler)
	{
		if (is_string($events)) $events = [$events];

		// store the handler for each of the events it represents
		foreach ($events as $event)
		{
			// check that we have a place to store the handler
			if (! array_key_exists($event, $this->handlers[static::MESSAGE_TYPE_STANDARD]))
			{
				$this->handlers[static::MESSAGE_TYPE_STANDARD][$event] = [];
			}

			$this->handlers[static::MESSAGE_TYPE_STANDARD][$event][] = $handler;
		}

		// create a new bare message, and store the events
		$m = $this->bareMessage(static::MESSAGE_TYPE_SUSCRIBE);
		$m->Payload['Events'] = $events;

		// finally, send the message
		$this->send($m);
	}
557260
public function registerHandler($contentType, ContentHandlerInterface $handler)
    {
        if (!is_string($contentType)) {
            throw new Exception('Invalid content handler specified.');
        }

        $this->handlers[$contentType] = $handler;
    }
52303
public function addHandler(array $handler, $key = null)
    {
        if (!isset($handler['type'])) {
            throw new InvalidArgumentException(
                'Handler type is required.'
            );
        }

        if (!is_string($key)) {
            $this->handlers[] = $handler;
        } else {
            $this->handlers[$key] = $handler;
        }

        return $this;
    }
900243
public function prepareHandler(Container $container)
    {
        $handler = $container->get('config')->get('user.handler') ?: NullUserHandler::class;

        $container->bindShared(UserHandlerInterface::class, $handler);
    }
369172
public function instantiate(string $handler) : EventHandler
    {
        $handler = ltrim($handler, '\\');
        if (false === $this->container->has($handler)) {
            throw new InvalidArgumentException(
                sprintf('Handler %s could not be found. Did you register it?', $handler)
            );
        }

        return $this->container->get($handler);
    }
486412
protected function register_handler(moodle1_handler $handler, array $elements) {

        // first iteration, push them to new array, indexed by name
        // to detect duplicates in names or paths
        $names = array();
        $paths = array();
        foreach($elements as $element) {
            if (!$element instanceof convert_path) {
                throw new convert_exception('path_element_wrong_class', get_class($element));
            }
            if (array_key_exists($element->get_name(), $names)) {
                throw new convert_exception('path_element_name_alreadyexists', $element->get_name());
            }
            if (array_key_exists($element->get_path(), $paths)) {
                throw new convert_exception('path_element_path_alreadyexists', $element->get_path());
            }
            $names[$element->get_name()] = true;
            $paths[$element->get_path()] = $element;
        }

        // now, for each element not having a processing object yet, assign the handler
        // if the element is not a memeber of a group
        foreach($paths as $key => $element) {
            if (is_null($element->get_processing_object()) and !$this->grouped_parent_exists($element, $paths)) {
                $paths[$key]->set_processing_object($handler);
            }
            // add the element path to the processor
            $this->xmlprocessor->add_path($element->get_path(), $element->is_grouped());
        }

        // done, store the paths (duplicates by path are discarded)
        $this->pathelements = array_merge($this->pathelements, $paths);

        // remove the injected plugin name element from the MOD and BLOCK paths
        // and register such collapsed path, too
        foreach ($elements as $element) {
            $path = $element->get_path();
            $path = preg_replace('/^\/MOODLE_BACKUP\/COURSE\/MODULES\/MOD\/(\w+)\//', '/MOODLE_BACKUP/COURSE/MODULES/MOD/', $path);
            $path = preg_replace('/^\/MOODLE_BACKUP\/COURSE\/BLOCKS\/BLOCK\/(\w+)\//', '/MOODLE_BACKUP/COURSE/BLOCKS/BLOCK/', $path);
            if (!empty($path) and $path != $element->get_path()) {
                $this->xmlprocessor->add_path($path, false);
            }
        }
    }
739986
public function handle($handler = null, array $params = null): ResponseInterface
    {
        $handler = $this->handler($handler);
        $params = $this->params($params);

        $parameters = null;
        if (!$handler instanceof \Closure) {
            [$class, $method] = $this->convert($handler);

            if ($method === null) {
                $key = $handler = $class;
            } else {
                $controller = new $class;
                $handler = [$controller, $method];
                $key = "{$class}::{$method}";
            }

            $parameters = self::optimizeGet($key);
            if ($parameters === false) {
                $parameters = Builder::getCallableParameters($handler, true);
                self::optimizeSet($key, $parameters);
            }
        }

        $result = $this->container->call($handler, $params, $parameters);

        if ($result instanceof ResponseInterface) {
            return $result;
        }

        /** @var Response $response */
        $response = $this->get('response');

        return $response->default($result);
    }