PHP Class Imbo\EventListener\Cors

This event listener will listen to all incoming OPTIONS requests and adds the correct headers required for CORS to function properly - all configured on a per-user/resource base.
Author: Espen Hovlandsdal ([email protected])
Inheritance: implements Imbo\EventListener\ListenerInterface
Afficher le fichier Open project: imbo/imbo Class Usage Examples

Méthodes publiques

Méthode Description
__construct ( array $params = [] ) Class constructor
getAllowedOrigins ( ) : array Returns an array of allowed origins
getSubscribedEvents ( )
invoke ( Imbo\EventManager\EventInterface $event ) Handle other requests
options ( Imbo\EventManager\EventInterface $event ) Handle the OPTIONS requests
setExposedHeaders ( Imbo\EventManager\EventInterface $event ) Right before the response is sent to the client, whitelist all included Imbo-headers in the "Access-Control-Expose-Headers"-header
subscribe ( Imbo\EventManager\EventInterface $event ) Subscribe to events based on configuration parameters

Private Methods

Méthode Description
originIsAllowed ( string $origin ) : boolean Check if the given origin is defined as an allowed origin

Method Details

__construct() public méthode

Class constructor
public __construct ( array $params = [] )
$params array Parameters for the listener

getAllowedOrigins() public méthode

Returns an array of allowed origins
public getAllowedOrigins ( ) : array
Résultat array The defined allowed origins

getSubscribedEvents() public static méthode

public static getSubscribedEvents ( )

invoke() public méthode

Handle other requests
public invoke ( Imbo\EventManager\EventInterface $event )
$event Imbo\EventManager\EventInterface The event instance

options() public méthode

Handle the OPTIONS requests
public options ( Imbo\EventManager\EventInterface $event )
$event Imbo\EventManager\EventInterface The event instance

setExposedHeaders() public méthode

Right before the response is sent to the client, whitelist all included Imbo-headers in the "Access-Control-Expose-Headers"-header
public setExposedHeaders ( Imbo\EventManager\EventInterface $event )
$event Imbo\EventManager\EventInterface The event instance

subscribe() public méthode

Subscribe to events based on configuration parameters
public subscribe ( Imbo\EventManager\EventInterface $event )
$event Imbo\EventManager\EventInterface The event instance