public function setModule($name, $module, $hook = 'after')
    {
        if (class_exists($module, true)) {
            switch ($hook) {
                case 'before':
                    $param = $this->request;
                    break;
                case 'after':
                    $param = $this->response;
                    break;
                default:
                    throw new \InvalidArgumentException("Invalid hook name!");
            }
            $this->registerModule($name, new $module($param), $hook);
        } else {
            throw new \OtherCode\Rest\Exceptions\ModuleNotFoundException('Module ' . $name . ' not found!');
        }
        return $this;
    }
public function setModule($name, $module, $hook = 'after')
    {
        if (class_exists($module, true)) {
            switch ($hook) {
                case 'before':
                    $param = $this->request;
                    break;
                case 'after':
                    $param = $this->response;
                    break;
                default:
                    throw new \InvalidArgumentException("Invalid hook name!");
            }
            $this->registerModule($name, new $module($param), $hook);
        } else {
            throw new \OtherCode\Rest\Exceptions\ModuleNotFoundException('Module ' . $name . ' not found!');
        }
        return $this;
    }
public function setModule ( $ name , $ module , $ hook = 'after' ) { if ( class_exists ( $ module , true ) ) { switch ( $ hook ) { case 'before' : $ param = $ this -> request ; break ; case 'after' : $ param = $ this -> response ; break ; default : throw new \ InvalidArgumentException ( "Invalid hook name!" ) ; } $ this -> registerModule ( $ name , new $ module ( $ param ) , $ hook ) ; } else { throw new \ OtherCode \ Rest \ Exceptions \ ModuleNotFoundException ( 'Module ' . $ name . ' not found!' ) ; } return $ this ; }
Set a new module instance
@param string $name Module unique name
@param string $module Module class name with namespace
@param string $hook The name the hook
@throws \InvalidArgumentException
@throws \OtherCode\Rest\Exceptions\ModuleNotFoundException
@return $this
Set a new module instance