# 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

<table><thead><tr><th width="142">Type</th><th width="166">Name</th><th>Description</th></tr></thead><tbody><tr><td>Host or Null</td><td>$host</td><td>The Host</td></tr><tr><td>Collection</td><td>$productHostings</td><td>Collection of all hostings which need to return a name</td></tr></tbody></table>

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)

```php
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:

```
php artisan hw:synchronizeHostingNames
```
