PHP Class Webiny\Component\Rest\Rest

Inheritance: use trait Webiny\Component\StdLib\ComponentTrait, use trait Webiny\Component\Router\RouterTrait, use trait Webiny\Component\Http\HttpTrait, use trait Webiny\Component\StdLib\StdObjectTrait, use trait Webiny\Component\StdLib\FactoryLoaderTrait
Show file Open project: Webiny/Framework Class Usage Examples

Public Methods

Method Description
__construct ( string $api, string $class ) Base constructor.
getEnvironment ( ) : string Get the name of current environment.
initRest ( string $api, string $url = '', string $method = '' ) : boolean | Rest Initializes the current Rest configuration, tries to match the current URL with the defined Path.
processRequest ( ) : boolean | CallbackResult Processes the current request and returns an instance of CallbackResult.
setEnvironment ( string $env = self::ENV_PRODUCTION ) Set the component environment.

Private Methods

Method Description
initializeCache ( ) Initializes the compiler cache driver.
isDevelopment ( ) : boolean Returns true if current environment is 'development'.
parseClass ( ) Calls the Parser to parse the class and then Compiler to create a compiled cache file of the parsed class.
processRouterResponse ( MatchedRoute $matchedRoute, ConfigObject $config, string $api ) : Rest Internal static method that is called when initRest method matches a URL agains the Path.
registerClass ( ) Registers the class and creates a compile cache version of it.

Method Details

__construct() public method

Base constructor.
public __construct ( string $api, string $class )
$api string Name of the api configuration.
$class string Name of the class that will been registered with the api.

getEnvironment() public method

Get the name of current environment.
public getEnvironment ( ) : string
return string

initRest() public static method

If match was successful, an instance of Rest class is returned, otherwise false.
public static initRest ( string $api, string $url = '', string $method = '' ) : boolean | Rest
$api string Api configuration Name
$url string Url on which the to match. Leave blank to use the current url.
$method string Name of the HTTP method that will be used to match the request. Leave blank to use the method from the current HTTP request.
return boolean | Rest

processRequest() public method

Processes the current request and returns an instance of CallbackResult.
public processRequest ( ) : boolean | CallbackResult
return boolean | Webiny\Component\Rest\Response\CallbackResult

setEnvironment() public method

If it's development, the component will output additional information inside the debug header.
public setEnvironment ( string $env = self::ENV_PRODUCTION )
$env string Can either be 'development' or 'production'