public function registerHandler($handler, $type = false)
    {
        if (!is_object($handler)) {
            throw new FilterExecutorException('Handler must be an object.');
        }

        if ($type === false) {
            // Try to guess handler type by class FQN.
            $type = $this->guessHandlerType($handler);

            if ($type === false) {
                throw new FilterExecutorException('Could not guess handler type. Please, provide the type for the handler manually.');
            }
        }

        if (!array_key_exists($type, $this->availableHandlerTypes)) {
            throw new FilterExecutorException(sprintf(
                'Handler type "%s" is not allowed (available handler types: [%s]).',
                $type, implode(', ', array_keys($this->availableHandlerTypes))
            ));
        }

        if (!array_key_exists($type, $this->registeredHandlers)) {
            $this->registeredHandlers[$type] = $handler;
        }

        return $this;
    }
public function registerHandler($handler, $type = false)
    {
        if (!is_object($handler)) {
            throw new FilterExecutorException('Handler must be an object.');
        }

        if ($type === false) {
            // Try to guess handler type by class FQN.
            $type = $this->guessHandlerType($handler);

            if ($type === false) {
                throw new FilterExecutorException('Could not guess handler type. Please, provide the type for the handler manually.');
            }
        }

        if (!array_key_exists($type, $this->availableHandlerTypes)) {
            throw new FilterExecutorException(sprintf(
                'Handler type "%s" is not allowed (available handler types: [%s]).',
                $type, implode(', ', array_keys($this->availableHandlerTypes))
            ));
        }

        if (!array_key_exists($type, $this->registeredHandlers)) {
            $this->registeredHandlers[$type] = $handler;
        }

        return $this;
    }
public function registerHandler ( $ handler , $ type = false ) { if ( ! is_object ( $ handler ) ) { throw new FilterExecutorException ( 'Handler must be an object.' ) ; } if ( $ type === false ) { // Try to guess handler type by class FQN. $ type = $ this -> guessHandlerType ( $ handler ) ; if ( $ type === false ) { throw new FilterExecutorException ( 'Could not guess handler type. Please, provide the type for the handler manually.' ) ; } } if ( ! array_key_exists ( $ type , $ this -> availableHandlerTypes ) ) { throw new FilterExecutorException ( sprintf ( 'Handler type "%s" is not allowed (available handler types: [%s]).' , $ type , implode ( ', ' , array_keys ( $ this -> availableHandlerTypes ) ) ) ) ; } if ( ! array_key_exists ( $ type , $ this -> registeredHandlers ) ) { $ this -> registeredHandlers [ $ type ] = $ handler ; } return $ this ; }
Registers specific filtration handler.

@param object|mixed $handler Any supported resource, which can handle filtration (QueryBuilder, ...)
@param string|bool  $type    The type of the handler

@return static
@throws FilterExecutorException on handler errors
Registers specific filtration handler .