src/SmartFactory/JsonApiRequestManager.php
public function registerApiRequestHandler($api_request, $handler_class_name)
    {
        if (empty($api_request)) {
            throw new \Exception("The API request is undefined (empty)!");
        }
        
        if (!empty($this->handler_table[$api_request])) {
            throw new \Exception("The API request '$api_request' has already the handler '" . $this->handler_table[$api_request] . "'!");
        }
        
        $this->handler_table[$api_request] = $handler_class_name;
        
        return true;
    }
public function registerApiRequestHandler($api_request, $handler_class_name)
    {
        if (empty($api_request)) {
            throw new \Exception("The API request is undefined (empty)!");
        }
        
        if (!empty($this->handler_table[$api_request])) {
            throw new \Exception("The API request '$api_request' has already the handler '" . $this->handler_table[$api_request] . "'!");
        }
        
        $this->handler_table[$api_request] = $handler_class_name;
        
        return true;
    }
public function registerApiRequestHandler ( $ api_request , $ handler_class_name ) { if ( empty ( $ api_request ) ) { throw new \ Exception ( "The API request is undefined (empty)!" ) ; } if ( ! empty ( $ this -> handler_table [ $ api_request ] ) ) { throw new \ Exception ( "The API request '$api_request' has already the handler '" . $ this -> handler_table [ $ api_request ] . "'!" ) ; } $ this -> handler_table [ $ api_request ] = $ handler_class_name ; return true ; }
Registers a handler action for an API request call.

@param string $api_request
The target API request.

@param string $handler_class_name
The name of the class for handling this API request.

Important! It should be a name of the class, neither the class instance
nor the class object. It is done to prevent situation that a wrong registration
of a handler breaks the handling of all requests.

The class instantiating and class loading occurs only if this API request
comes.

@return boolean
Returns true if the registration was successfull, otherwise false.

@throws \Exception
It might throw the following exceptions in the case of any errors:

- if the request name is not specified.
- if the request already has a handler.

@see registerPreProcessHandler()
@see registerPostProcessHandler()
@see registerDefaultHandler()

@author Oleg Schildt
Registers a handler action for an API request call .