Hosting Handler

Synchronize names

This is an optional feature which can be integrated in any hosting module. Hostware will detect if the function is implemented and then starts querying the names hourly.

hostware will call the function once for each host you have configured for the module. If the module does not support hosts, the function will be called just once for all hostings.

getNames()

Return a name for each of the given hostings.

Parameters

Type

Name

Description

Host or Null

$host

The Host

Collection

$productHostings

Collection of all hostings which need to return a name

None.

Response

Array with the hosting ID as key and the name as value.

If the hosting has no name or could not be queried, just dont include the hosting in the response array.

Example Code (Plesk integration)

public function getNames(Host $host, Collection $productHostings): array {
	$names = [];


	foreach ($productHostings as $item) {
		$response  = $this->getClient($host)->webspace()->get('guid', $item->custom_fields['pleskWebspaceGuid']);

		$names[$item->id] = $response->name;
	}

	return $names;
}

Testing

Run the following console command:

Was this helpful?