Registers handlers from config.

@param array $handlersConfig

@return $this
423280
protected function registerHandlers(array $handlersConfig)
    {
        $overrideHandlers = Arr::get($handlersConfig, 'override', []);
        if (count($overrideHandlers) > 0) {
            HandlerFactory::setHandlers($overrideHandlers);

            return $this;
        }

        foreach (Arr::get($handlersConfig, 'custom', []) as $handler) {
            HandlerFactory::register($handler);
        }

        return $this;
    }
355801
protected function add_handler( $dependency ) {
		if ( $this->hasConfigKey( $dependency ) ) {
			$handler = $this->hasConfigKey( self::KEY_HANDLERS, $dependency )
				? $this->getConfigKey( self::KEY_HANDLERS, $dependency )
				: $this->get_default_handler( $dependency );
			if ( $handler ) {
				$this->handlers[ $dependency ] = new $handler;
			}
		}
	}
636091
public function register($handledErrors = E_ALL)
    {
        $errHandler = [$this, 'handleError'];
        $exHandler = [$this, 'handleException'];

        $handledErrors = is_int($handledErrors) ? $handledErrors : E_ALL;

        set_error_handler($errHandler, $handledErrors);
        set_exception_handler($exHandler);

        return $this;
    }
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;
    }
1360163
public function setHandler($handler)
    {
        $handler = new $handler($this->config);

        if (!$handler instanceof HandlerInterface) {
            throw new \RuntimeException('Handler not initialized. Please use Handler class instanceof HandlerInterface.');
        }

        $this->handler = $handler;

        return $this;
    }
233700
public static function init($config = null)
    {
        self::registerDevelopmentErrorHandler();
        self::registerExceptionHandler();

        if ($config === null) {
            $config = static::loadAppConfig();
        }

        static::addCoreModule($config);

        $serviceConfig = isset($config['service_manager']) ? $config['service_manager'] : array();
        $listeners = isset($config['listeners'])? $config['listeners'] : array();
        $serviceManager = new ServiceManager(new ServiceConfig($serviceConfig));

        $serviceManager->setService('ApplicationConfig', $config);
        $serviceManager->get('ModuleManager')->loadModules();

        return $serviceManager->get('Application')->bootstrap($listeners);
    }
331078
protected function rm__load_tables(array &$config, array $handlers) {
		if (isset($handlers['configure'])) {
			$conf = $handlers['configure'];
			if (is_array($conf)) {
				if (isset($conf['tables'])) {
					foreach ($conf['tables'] as $table) {
						$config['tables'][] = $table;
					}
				}
			}
			else { // callback
				$config = $conf($config);
			}
		}
	}
1224121
protected function registerSwooleEvents($handler, array $events)
    {
        foreach ($events as $event => $beanName) {
            $object = bean($beanName);
            $method = SwooleEvent::getHandlerFunction($event);
            $handler->on($event, [$object, $method]);
        }
    }
496787
public function initialize(array $config) {
        parent::initialize($config);

        // set request
        $this->ctrl = $this->getController();
        $this->cookies = (new CookieCollection())->createFromServerRequest($this->ctrl->getRequest());
    }
114114
@SuppressWarnings("rawtypes")
   public void setupConfigHandlers(Binding binding, CommonConfig config)
   {
      if (config != null) {
         //start with the use handlers only to remove the previously set configuration
         List<Handler> userHandlers = getNonConfigHandlers(binding.getHandlerChain());
         List<Handler> handlers = convertToHandlers(config.getPreHandlerChains(), binding.getBindingID(), true); //PRE
         handlers.addAll(userHandlers); //ENDPOINT
         handlers.addAll(convertToHandlers(config.getPostHandlerChains(), binding.getBindingID(), false)); //POST
         binding.setHandlerChain(handlers);
      }
   }
1133648
protected function registerHandler()
	{
		$this->app['exception'] = $this->app->share(function($app)
		{
			return new Handler($app, $app['exception.plain'], $app['exception.debug']);
		});
	}
21746
public function registerConfiguredHooks(string $config = '')
    {
        if (empty($config)) {
            $config = 'app.hooks';
        }

        $hooks = Collection::make($this->config[$config]);

        (new HooksRepository($this))->load($hooks->all());
    }
1121242
public static function register(LoggerInterface $logger = null, $cfg = null) {
            self::$registered = true;
            $class = get_called_class();
            $handler = new $class($logger, $cfg);

            register_shutdown_function([$handler, 'handle']);
            self::$lastRegisteredHandler = &$handler;

            return $handler;
        }
572098
public function initialize(array $config = []) {
		$config += (array)Configure::read('Captcha');
		parent::initialize($config);

		$engine = $this->getConfig('engine');
		$this->_engine = new $engine($this->getConfig());
		$this->_captchasTable = TableRegistry::get('Captcha.Captchas');
	}
320200
public function initialize(array $config) {
		$this->setTable('tags_tags');
		$this->setDisplayField('label'); // Change to name?
		$this->addBehavior('Timestamp');

		/** @var array|bool|string|null $slugger */
		$slugger = Configure::read('Tags.slugBehavior');
		if (!$slugger) {
			return;
		}
		if ($slugger === true) {
			if (Plugin::loaded('Tools')) {
				$this->addBehavior('Tools.Slugged');
				return;
			}
			if (Plugin::loaded('Muffin/Slug')) {
				$this->addBehavior('Muffin/Slug.Slug');
				return;
			}

			throw new RuntimeException('Auto-slug behavior not found, plugin not loaded.');
		}

		$config = [];
		if (!is_string($slugger)) {
			$config = current($slugger);
			$slugger = key($slugger);
		}
		$this->addBehavior($slugger, $config);
	}
1340771
public function add_handler( HandlerInterface $handler, $name = NULL ) {

		( $name === null ) and $name = spl_object_hash( $handler );
		if ( ! is_string( $name ) || array_key_exists( $name, $this->handlers ) ) {
			return $this;
		}

		$this->handlers[ $name ] = $handler;

		return $this;
	}
1137129
public function initialize(array $config)
    {
        parent::initialize($config);

        $this->setController($this->_registry->getController());

        $this->_registerFromConfigure();
    }