-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathLocale.php
35 lines (28 loc) · 952 Bytes
/
Locale.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
// Copyright 1999-2025. WebPros International GmbH.
namespace PleskX\Api\Operator;
use PleskX\Api\Struct\Locale as Struct;
class Locale extends \PleskX\Api\Operator
{
/**
* @param string|null $id
*
* @return Struct\Info|Struct\Info[]
*/
public function get($id = null)
{
$locales = [];
$packet = $this->client->getPacket();
$filter = $packet->addChild($this->wrapperTag)->addChild('get')->addChild('filter');
if (!is_null($id)) {
$filter->addChild('id', $id);
}
$response = $this->client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
foreach ($response->locale->get->result ?? [] as $localeInfo) {
if (!is_null($localeInfo->info)) {
$locales[(string) $localeInfo->info->id] = new Struct\Info($localeInfo->info);
}
}
return !is_null($id) ? reset($locales) : $locales;
}
}