Documentation

HelperService
in package

Service with some helpful methods that we use in different locations.

Table of Contents

$dateFormatter  : DateFormatterInterface
Drupal\Core\Datetime\DateFormatterInterface definition.
__construct()  : mixed
Constructs a new HelperService object.
createIsoDate()  : string
Create a ISO8601 timestamp that Microsoft Graph API can use.
formatDate()  : string
Format a ISO8601 date into something more readable.
getApiConfig()  : false|array<string|int, mixed>
Retrieve the API settings from the config.
getAuthScopes()  : string|array<string|int, mixed>
Get the auth scopes string.
getTsFromDate()  : string
Generate a unix timestamp from a date.

Properties

$dateFormatter

Drupal\Core\Datetime\DateFormatterInterface definition.

protected DateFormatterInterface $dateFormatter

Methods

__construct()

Constructs a new HelperService object.

public __construct(DateFormatterInterface $date_formatter) : mixed
Parameters
$date_formatter : DateFormatterInterface

The DateFormatterInterface definition.

Return values
mixed

createIsoDate()

Create a ISO8601 timestamp that Microsoft Graph API can use.

public createIsoDate(int $timestamp) : string
Parameters
$timestamp : int

The unix timestamp we want to use to create the date.

Return values
string

The ISO8601 formatted date.

formatDate()

Format a ISO8601 date into something more readable.

public formatDate(string $date[, string $timezone = 'UTC' ][, string $format = 'd-m-Y H:i' ]) : string
Parameters
$date : string

The ISO8601 date.

$timezone : string = 'UTC'

The timezone.

$format : string = 'd-m-Y H:i'

The format we want to convert to.

Tags
throws
Exception
Return values
string

The formatted date.

getApiConfig()

Retrieve the API settings from the config.

public getApiConfig() : false|array<string|int, mixed>
Return values
false|array<string|int, mixed>

The array with the settings, or FALSE.

getAuthScopes()

Get the auth scopes string.

public getAuthScopes([bool $asArray = FALSE ]) : string|array<string|int, mixed>
Parameters
$asArray : bool = FALSE

If the returned value needs to be a array, defaults to FALSE.

Return values
string|array<string|int, mixed>

The space seperated list of auth scopes or a raw array of scopes.

getTsFromDate()

Generate a unix timestamp from a date.

public getTsFromDate(string $date[, string $timezone = 'UTC' ]) : string
Parameters
$date : string

The date.

$timezone : string = 'UTC'

The timezone.

Return values
string

The unix timestamp.

Search results