public function register($sType, $sUserFunction, $aOptions)
    {
        if($sType != $this->getName())
        {
            return false;
        }

        if(!is_string($sUserFunction))
        {
            throw new \Jaxon\Exception\Error($this->trans('errors.functions.invalid-declaration'));
        }

        if(is_string($aOptions))
        {
            $aOptions = ['include' => $aOptions];
        }
        if(!is_array($aOptions))
        {
            throw new \Jaxon\Exception\Error($this->trans('errors.functions.invalid-declaration'));
        }

        // Check if an alias is defined
        $sFunctionName = $sUserFunction;
        foreach($aOptions as $sName => $sValue)
        {
            if($sName == 'alias')
            {
                $sFunctionName = $sValue;
                break;
            }
        }

        $this->aFunctions[$sFunctionName] = $aOptions;
        jaxon()->di()->set($sFunctionName, function () use ($sFunctionName, $sUserFunction) {
            $xUserFunction = new \Jaxon\Request\Support\UserFunction($sUserFunction);

            $aOptions = $this->aFunctions[$sFunctionName];
            foreach($aOptions as $sName => $sValue)
            {
                $xUserFunction->configure($sName, $sValue);
            }

            return $xUserFunction;
        });

        return true;
    }
public function register($sType, $sUserFunction, $aOptions)
    {
        if($sType != $this->getName())
        {
            return false;
        }

        if(!is_string($sUserFunction))
        {
            throw new \Jaxon\Exception\Error($this->trans('errors.functions.invalid-declaration'));
        }

        if(is_string($aOptions))
        {
            $aOptions = ['include' => $aOptions];
        }
        if(!is_array($aOptions))
        {
            throw new \Jaxon\Exception\Error($this->trans('errors.functions.invalid-declaration'));
        }

        // Check if an alias is defined
        $sFunctionName = $sUserFunction;
        foreach($aOptions as $sName => $sValue)
        {
            if($sName == 'alias')
            {
                $sFunctionName = $sValue;
                break;
            }
        }

        $this->aFunctions[$sFunctionName] = $aOptions;
        jaxon()->di()->set($sFunctionName, function () use ($sFunctionName, $sUserFunction) {
            $xUserFunction = new \Jaxon\Request\Support\UserFunction($sUserFunction);

            $aOptions = $this->aFunctions[$sFunctionName];
            foreach($aOptions as $sName => $sValue)
            {
                $xUserFunction->configure($sName, $sValue);
            }

            return $xUserFunction;
        });

        return true;
    }
public function register ( $ sType , $ sUserFunction , $ aOptions ) { if ( $ sType != $ this -> getName ( ) ) { return false ; } if ( ! is_string ( $ sUserFunction ) ) { throw new \ Jaxon \ Exception \ Error ( $ this -> trans ( 'errors.functions.invalid-declaration' ) ) ; } if ( is_string ( $ aOptions ) ) { $ aOptions = [ 'include' => $ aOptions ] ; } if ( ! is_array ( $ aOptions ) ) { throw new \ Jaxon \ Exception \ Error ( $ this -> trans ( 'errors.functions.invalid-declaration' ) ) ; } // Check if an alias is defined $ sFunctionName = $ sUserFunction ; foreach ( $ aOptions as $ sName => $ sValue ) { if ( $ sName == 'alias' ) { $ sFunctionName = $ sValue ; break ; } } $ this -> aFunctions [ $ sFunctionName ] = $ aOptions ; jaxon ( ) -> di ( ) -> set ( $ sFunctionName , function ( ) use ( $ sFunctionName , $ sUserFunction ) { $ xUserFunction = new \ Jaxon \ Request \ Support \ UserFunction ( $ sUserFunction ) ; $ aOptions = $ this -> aFunctions [ $ sFunctionName ] ; foreach ( $ aOptions as $ sName => $ sValue ) { $ xUserFunction -> configure ( $ sName , $ sValue ) ; } return $ xUserFunction ; } ) ; return true ; }
Register a user defined function

@param string        $sType          The type of request handler being registered
@param string        $sUserFunction  The name of the function being registered
@param array|string  $aOptions       The associated options

@return \Jaxon\Request\Request
Register a user defined function