class GraphService

This is the GraphService.

The main service that gets and sets data in Microsoft 365.

Properties

protected AuthenticationServiceInterface $authService

Drupal\o365\AuthenticationServiceInterface definition.

protected AuthmapInterface $authmap

The externalauth authmap service.

protected CacheBackendInterface $cacheBackend

The cache backend service.

protected AccountProxyInterface $currentUser

The current user account.

protected LoggerChannelInterface $logger

The modules logger.

protected O365LoggerServiceInterface $messenger

The logger service.

Methods

__construct(AuthenticationServiceInterface $authenticationService, O365LoggerServiceInterface $messenger, CacheBackendInterface $cacheBackend, LoggerChannelFactoryInterface $loggerChannelFactory, AuthmapInterface $authmap, AccountProxyInterface $currentUser)

Constructs a new GraphService object.

GraphCollectionRequest|bool
getCollectionData(string $endpoint, bool|string $returnType = FALSE, bool|string $version = FALSE)

Get a collection of data.

bool|string
getCurrentUserId()

Determine the office user ID.

mixed
getGraphData(string $endpoint, string $type = 'GET', bool $raw = FALSE, bool|string $version = FALSE, bool|string $returnType = FALSE, array $headers = [])

Get data from the MS GraphAPI.

int
getTimeout()

Get the Graph API timeout.

mixed
sendGraphData(string $endpoint, mixed $data = [], string $type = 'POST', bool $raw = FALSE, bool|string $version = FALSE, bool|string $returnType = FALSE, array $headers = [])

Send data to the MS GraphAPI.

void
setTimeout(int $timeout)

Set the Graph API timeout.

Details

at line 80
__construct(AuthenticationServiceInterface $authenticationService, O365LoggerServiceInterface $messenger, CacheBackendInterface $cacheBackend, LoggerChannelFactoryInterface $loggerChannelFactory, AuthmapInterface $authmap, AccountProxyInterface $currentUser)

Constructs a new GraphService object.

Parameters

AuthenticationServiceInterface $authenticationService

The AuthenticationServiceInterface definition.

O365LoggerServiceInterface $messenger

The O365LoggerServiceInterface definition.

CacheBackendInterface $cacheBackend

The CacheBackendInterface definition.

LoggerChannelFactoryInterface $loggerChannelFactory

The logger channel factory. Used to log to the watchdog.

AuthmapInterface $authmap

The externalauth authmap service.

AccountProxyInterface $currentUser

The current user account.

at line 265
GraphCollectionRequest|bool getCollectionData(string $endpoint, bool|string $returnType = FALSE, bool|string $version = FALSE)

Get a collection of data.

Parameters

string $endpoint

The graph endpoint we want data from.

bool|string $returnType

The return type we want to get.

bool|string $version

The version of the graph api that is used.

Return Value

GraphCollectionRequest|bool

The collection request.

Exceptions

TempStoreException
IdentityProviderException
GraphException

at line 296
bool|string getCurrentUserId()

Determine the office user ID.

Return Value

bool|string

The ID or FALSE if not logged in via Office.

at line 111
mixed getGraphData(string $endpoint, string $type = 'GET', bool $raw = FALSE, bool|string $version = FALSE, bool|string $returnType = FALSE, array $headers = [])

Get data from the MS GraphAPI.

Parameters

string $endpoint

The graph endpoint we want data from.

string $type

The type of request we want to do.

bool $raw

This determines if we want a raw body or not.

bool|string $version

The version of the graph api that is used.

bool|string $returnType

The return type we want to get.

array $headers

An array of headers to send.

Return Value

mixed

The data retrieved from the Graph API.

Exceptions

TempStoreException
GraphException

at line 306
int getTimeout()

Get the Graph API timeout.

Return Value

int

The timeout in seconds.

at line 146
mixed sendGraphData(string $endpoint, mixed $data = [], string $type = 'POST', bool $raw = FALSE, bool|string $version = FALSE, bool|string $returnType = FALSE, array $headers = [])

Send data to the MS GraphAPI.

Parameters

string $endpoint

The graph endpoint we want data from.

mixed $data

Sent data.

string $type

The type of request we want to do.

bool $raw

This determines if we want a raw body or not.

bool|string $version

The version of the graph api that is used.

bool|string $returnType

The return type we want to get.

array $headers

An array of headers to send.

Return Value

mixed

The data retrieved from the Graph API.

Exceptions

TempStoreException
GuzzleException
GraphException

at line 316
void setTimeout(int $timeout)

Set the Graph API timeout.

Parameters

int $timeout

The timeout amount in seconds.

Return Value

void