src/php/main/Eix/Core/Responders/Http.php
private function getFunctionName($httpMethod)
    {
        if ($this->getRequest()) {
            $functionName = null;
            // Prefix starts with 'http'.
            $functionPrefix = 'http';
            // The HTTP method is then appended.
            $functionPrefix .= ucfirst(strtolower($httpMethod));
            // If an action has been captured in the URI, append it too.
            $action = $this->getRequest()->getParameter('action');
            if ($action) {
                $functionPrefix .= ucfirst($action);
                // If there is an action, check whether the function is likely
                // to exist.
                if (!$this->isBaseFunctionAvailable($functionPrefix)) {
                    throw new \Eix\Services\Net\Http\NotFoundException(
                        "This responder does not have any methods starting with {$functionPrefix}."
                    );
                }
            }

            $found = false;
            $acceptedContentTypes = $this->getRequest()->getAcceptedContentTypes();
            // Append a token to the function name, based on the requested content
            foreach ($acceptedContentTypes as $contentType => $quality) {
                try {
                    $contentTypeToken = \Eix\Core\Requests\Http::getContentTypeToken($contentType);
                    // Append the token for the response's expected content type.
                    $functionName = $functionPrefix . 'For' . $contentTypeToken;
                    Logger::get()->debug("Trying {$functionName} for {$contentType}...");
                    // Check whether a method with that name exists.
                    if (method_exists($this, $functionName)) {
                        return $functionName;
                    }
                } catch (\InvalidArgumentException $exception) {
                    // This content type is invalid, keep on checking.
                }
            }

            // Although a base method exists, it does not for this content type,
            // so that's a 406.
            throw new \Eix\Services\Net\Http\NotAcceptableException(
                "This responder cannot serve content type {$contentType}."
            );
        } else {
            // If there is no request, return the generic responder method.
            return 'httpGetForAll';
        }
    }
private function getFunctionName($httpMethod)
    {
        if ($this->getRequest()) {
            $functionName = null;
            // Prefix starts with 'http'.
            $functionPrefix = 'http';
            // The HTTP method is then appended.
            $functionPrefix .= ucfirst(strtolower($httpMethod));
            // If an action has been captured in the URI, append it too.
            $action = $this->getRequest()->getParameter('action');
            if ($action) {
                $functionPrefix .= ucfirst($action);
                // If there is an action, check whether the function is likely
                // to exist.
                if (!$this->isBaseFunctionAvailable($functionPrefix)) {
                    throw new \Eix\Services\Net\Http\NotFoundException(
                        "This responder does not have any methods starting with {$functionPrefix}."
                    );
                }
            }

            $found = false;
            $acceptedContentTypes = $this->getRequest()->getAcceptedContentTypes();
            // Append a token to the function name, based on the requested content
            foreach ($acceptedContentTypes as $contentType => $quality) {
                try {
                    $contentTypeToken = \Eix\Core\Requests\Http::getContentTypeToken($contentType);
                    // Append the token for the response's expected content type.
                    $functionName = $functionPrefix . 'For' . $contentTypeToken;
                    Logger::get()->debug("Trying {$functionName} for {$contentType}...");
                    // Check whether a method with that name exists.
                    if (method_exists($this, $functionName)) {
                        return $functionName;
                    }
                } catch (\InvalidArgumentException $exception) {
                    // This content type is invalid, keep on checking.
                }
            }

            // Although a base method exists, it does not for this content type,
            // so that's a 406.
            throw new \Eix\Services\Net\Http\NotAcceptableException(
                "This responder cannot serve content type {$contentType}."
            );
        } else {
            // If there is no request, return the generic responder method.
            return 'httpGetForAll';
        }
    }
private function getFunctionName ( $ httpMethod ) { if ( $ this -> getRequest ( ) ) { $ functionName = null ; // Prefix starts with 'http'. $ functionPrefix = 'http' ; // The HTTP method is then appended. $ functionPrefix .= ucfirst ( strtolower ( $ httpMethod ) ) ; // If an action has been captured in the URI, append it too. $ action = $ this -> getRequest ( ) -> getParameter ( 'action' ) ; if ( $ action ) { $ functionPrefix .= ucfirst ( $ action ) ; // If there is an action, check whether the function is likely // to exist. if ( ! $ this -> isBaseFunctionAvailable ( $ functionPrefix ) ) { throw new \ Eix \ Services \ Net \ Http \ NotFoundException ( "This responder does not have any methods starting with {$functionPrefix}." ) ; } } $ found = false ; $ acceptedContentTypes = $ this -> getRequest ( ) -> getAcceptedContentTypes ( ) ; // Append a token to the function name, based on the requested content foreach ( $ acceptedContentTypes as $ contentType => $ quality ) { try { $ contentTypeToken = \ Eix \ Core \ Requests \ Http :: getContentTypeToken ( $ contentType ) ; // Append the token for the response's expected content type. $ functionName = $ functionPrefix . 'For' . $ contentTypeToken ; Logger :: get ( ) -> debug ( "Trying {$functionName} for {$contentType}..." ) ; // Check whether a method with that name exists. if ( method_exists ( $ this , $ functionName ) ) { return $ functionName ; } } catch ( \ InvalidArgumentException $ exception ) { // This content type is invalid, keep on checking. } } // Although a base method exists, it does not for this content type, // so that's a 406. throw new \ Eix \ Services \ Net \ Http \ NotAcceptableException ( "This responder cannot serve content type {$contentType}." ) ; } else { // If there is no request, return the generic responder method. return 'httpGetForAll' ; } }
Returns a function name that represents the method and response's
expected content type.

e.g. httpGetForHtml represents a GET request expecting HTML back.
e.g. httpPostForJson represents a POST request expecting JSON back.
e.g. httpPutForAll represents a PUT request expecting whatever back.
Returns a function name that represents the method and response s expected content type .