Overview

Namespaces

  • ApiBundle
    • DataFixtures
      • Faker
        • Provider
    • DependencyInjection
    • Doctrine
      • DBAL
        • Type
      • ORM
        • Filter
          • User
    • Entity
    • EventListener
      • Doctrine
    • Manager
    • Utils
  • FrontBundle
    • Bundle
      • UserBundle
    • Client
      • Exception
    • Controller
    • DependencyInjection
    • Form
      • DataTransformer
      • Type
    • Menu
    • Security
      • Http
        • Authentication
    • Services
      • Http
    • Twig
    • Utils

Classes

  • ApiClient

Interfaces

  • ClientInterface
  • Overview
  • Namespace
  • Class

Class ApiClient

API client. For now is a Guzzle client which has been extended to allow to pass route names instead of just the URI and easily pass the token.

FrontBundle\Client\ApiClient implements FrontBundle\Client\ClientInterface
Namespace: FrontBundle\Client
Author: Théo FIDRY theo.fidry@gmail.com
Located at FrontBundle/Client/ApiClient.php
Methods summary
public
# __construct( GuzzleHttp\ClientInterface $client, FrontBundle\Services\Http\RequestBuilder $requestBuilder )

Parameters

$client
$requestBuilder

Throws

InvalidArgumentException
public Psr\Http\Message\RequestInterface
# createRequest( string $method, string|null $url = null, string|null $token = null, array $options = [] )

Creates and return a new Request object. All get, head, etc. methods are generated via this method.

Creates and return a new Request object. All get, head, etc. methods are generated via this method.

Parameters

$method
HTTP method.
$url
URL, URL, URI or route name.
$token
API token.
$options

Array of request options to apply. can have the keys: - headers: array - parameters (route parameters if $url is a route and not an URI) - body: string|null

Returns

Psr\Http\Message\RequestInterface

Throws

Symfony\Component\Routing\Exception\RouteNotFoundException
If the named route doesn't exist
Symfony\Component\Routing\Exception\MissingMandatoryParametersException
When some parameters are missing that are mandatory for the route
Symfony\Component\Routing\Exception\InvalidParameterException

When a parameter value for a placeholder is not correct because it does not match the requirement

Implementation of

FrontBundle\Client\ClientInterface::createRequest()
public ResponseInterface
# request( string $method, string|null $url = null, string|null $token = null, array $options = [] )

Sends a request.

Sends a request.

Parameters

$method
HTTP method
$url
URL, URI or route name.
$token
API token.
$options
Options applied to the request.

Returns

ResponseInterface

Throws

ClientException

Implementation of

FrontBundle\Client\ClientInterface::request()
public ResponseInterface
# send( Psr\Http\Message\RequestInterface $request )

Sends a single request.

Sends a single request.

Parameters

$request
Request to send

Returns

ResponseInterface

Throws

ClientException

Implementation of

FrontBundle\Client\ClientInterface::send()
API documentation generated by ApiGen