Skip to content

Latest commit

 

History

History
520 lines (274 loc) · 9.79 KB

File metadata and controls

520 lines (274 loc) · 9.79 KB

CommonGateway\CoreBundle\Service\RequestService

Handles incoming request from endpoints or controllers that relate to the gateways object structure (eav).

Methods

Name Description
__construct The constructor sets al needed variables.
checkEmbedded If embedded should be shown or not.
createResponse Creating the response object.
federationProxyHandler Runs a federated request to a multitude of proxies and aggregrates the results.
getFederationConfig Update configuration from federation query parameters, sets timeout and http_errors, unsets the query parameters.
getFederationSources Takes the config array and includes or excludes sources for federated requests based upon query parameters.
getId Get the ID from given parameters.
getSchema Get the schema from given parameters returns false if no schema could be established.
getScopes Get a scopes array for the current user (or of the anonymus if no user s logged in).
proxyHandler Handles a proxy Endpoint.
proxyRequestHandler Determines the proxy source from configuration, then use proxy handler to proxy the request.
realRequestQueryAll A function to replace Request->query->all() because Request->query->all() will replace some characters with an underscore.
requestHandler Handles incoming requests and is responsible for generating a response.
serializeData Determines the right content type and serializes the data accordingly.
shouldWeUnsetEmbedded Handle the Application Endpoint Configuration for embedded. If embedded should be shown or not.
useRelayRating Checks if the query parameter to relay rating is set and if so, return the value while unsetting the query parameter.

RequestService::__construct

Description

public __construct (\EntityManagerInterface $entityManager, \GatewayResourceService $resourceService, \MappingService $mappingService, \ValidationService $validationService, \FileSystemHandleService $fileSystemService, \CacheService $cacheService, \ReadUnreadService $readUnreadService, \SynchronizationService $syncService, \CallService $callService, \Security $security, \EventDispatcherInterface $eventDispatcher, \SerializerInterface $serializer, \SessionInterface $session, \LoggerInterface $requestLogger, \DownloadService $downloadService)

The constructor sets al needed variables.

Parameters

  • (\EntityManagerInterface) $entityManager : The entity manager
  • (\GatewayResourceService) $resourceService : The resource service
  • (\MappingService) $mappingService : The mapping service
  • (\ValidationService) $validationService : The validation service
  • (\FileSystemHandleService) $fileSystemService : The file system service
  • (\CacheService) $cacheService : The cache service
  • (\ReadUnreadService) $readUnreadService : The read unread service
  • (\SynchronizationService) $syncService : The SynchronizationService.
  • (\CallService) $callService : The call service
  • (\Security) $security : Security
  • (\EventDispatcherInterface) $eventDispatcher : Event dispatcher
  • (\SerializerInterface) $serializer : The serializer
  • (\SessionInterface) $session : The current session
  • (\LoggerInterface) $requestLogger : The logger interface
  • (\DownloadService) $downloadService : The download service

Return Values

void


RequestService::checkEmbedded

Description

public checkEmbedded (object|array $result)

If embedded should be shown or not.

Parameters

  • (object|array) $result : fetched result

Return Values

array|null


RequestService::createResponse

Description

public createResponse ( $data)

Creating the response object.

Parameters

  • () $data

Return Values

\Response


RequestService::federationProxyHandler

Description

public federationProxyHandler (\Collection $proxies, string $path, array $config)

Runs a federated request to a multitude of proxies and aggregrates the results.

Parameters

  • (\Collection) $proxies : The proxies to send the request to.
  • (string) $path : The path to send the request to.
  • (array) $config : The call configuration.

Return Values

\Response

The resulting response.

Throws Exceptions

\Exception


RequestService::getFederationConfig

Description

public getFederationConfig (array $config)

Update configuration from federation query parameters, sets timeout and http_errors, unsets the query parameters.

Parameters

  • (array) $config : The original call configuration including the federation query parameters.

Return Values

array

The updated call configuration.


RequestService::getFederationSources

Description

public getFederationSources (array $config, \Collection $proxies)

Takes the config array and includes or excludes sources for federated requests based upon query parameters.

Parameters

  • (array) $config : The call configuration.
  • (\Collection) $proxies : The full list of proxies configured for the endpoint.

Return Values

\Collection

The list of proxies that remains after including or excluding sources.

Throws Exceptions

\Exception

Thrown when both include and exclude query parameters are given.


RequestService::getId

Description

public getId (void)

Get the ID from given parameters.

Parameters

This function has no parameters.

Return Values

string|false


RequestService::getSchema

Description

public getSchema (array $parameters)

Get the schema from given parameters returns false if no schema could be established.

Parameters

  • (array) $parameters

Return Values

\Entity|false


RequestService::getScopes

Description

public getScopes (void)

Get a scopes array for the current user (or of the anonymus if no user s logged in).

Parameters

This function has no parameters.

Return Values

array


RequestService::proxyHandler

Description

public proxyHandler (array $data, array $configuration)

Handles a proxy Endpoint.

todo: we want to merge proxyHandler() and requestHandler() code at some point.

Parameters

  • (array) $data : The data from the call
  • (array) $configuration : The configuration from the call

Return Values

\Response

The data as returned bij the original source


RequestService::proxyRequestHandler

Description

public proxyRequestHandler (array $parameters, array $configuration)

Determines the proxy source from configuration, then use proxy handler to proxy the request.

Parameters

  • (array) $parameters : The parameters of the request.
  • (array) $configuration : The configuration of the action.

Return Values

array

The result of the proxy.


RequestService::realRequestQueryAll

Description

public realRequestQueryAll (string|null $queryString)

A function to replace Request->query->all() because Request->query->all() will replace some characters with an underscore.

This function will not.

Parameters

  • (string|null) $queryString : A queryString from a request if we want to give it to this function instead of using global var $_SERVER.

Return Values

array

An array with all query parameters.


RequestService::requestHandler

Description

public requestHandler (array $data, array $configuration)

Handles incoming requests and is responsible for generating a response.

todo: we want to merge requestHandler() and proxyHandler() code at some point.

Parameters

  • (array) $data : The data from the call
  • (array) $configuration : The configuration from the call

Return Values

\Response

The modified data

Throws Exceptions

\Exception


RequestService::serializeData

Description

public serializeData (array $data, mixed $contentType)

Determines the right content type and serializes the data accordingly.

Parameters

  • (array) $data : The data to serialize.
  • (mixed) $contentType : The content type to determine.

Return Values

string

The serialized data.


RequestService::shouldWeUnsetEmbedded

Description

public shouldWeUnsetEmbedded (object|array $result, array $embeddedConfig)

Handle the Application Endpoint Configuration for embedded. If embedded should be shown or not.

Configuration Example: ['global']['out']['embedded']['unset'] = true
Configuration Example 2: ['global']['out']['embedded']['unset']['except'] = ['application/json+ld', 'application/ld+json'].

Parameters

  • (object|array) $result : fetched result
  • (array) $embeddedConfig : Application configuration ['out']['embedded']

Return Values

array|null

The updated result.


RequestService::useRelayRating

Description

public useRelayRating (array $config)

Checks if the query parameter to relay rating is set and if so, return the value while unsetting the query parameter.

Parameters

  • (array) $config : The call configuration.

Return Values

bool