Skip to content

Commit 10fb37a

Browse files
laurisbmrsombre
authored andcommitted
Add PhpSettings to Webspace (#56)
1 parent 36c6360 commit 10fb37a

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

src/Api/Operator/Webspace.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,24 @@ public function getPhysicalHostingDescriptor()
2525
return new Struct\PhysicalHostingDescriptor($response);
2626
}
2727

28+
/**
29+
* @param string $field
30+
* @param integer|string $value
31+
* @return Struct\PhpSettings
32+
*/
33+
public function getPhpSettings($field, $value)
34+
{
35+
$packet = $this->_client->getPacket();
36+
$getTag = $packet->addChild($this->_wrapperTag)->addChild('get');
37+
38+
$getTag->addChild('filter')->addChild($field, $value);
39+
$getTag->addChild('dataset')->addChild('php-settings');
40+
41+
$response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
42+
43+
return new Struct\PhpSettings($response);
44+
}
45+
2846
/**
2947
* @param array $properties
3048
* @param array|null $hostingProperties
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
// Copyright 1999-2019. Parallels IP Holdings GmbH.
3+
4+
namespace PleskX\Api\Struct\Webspace;
5+
6+
class PhpSettings extends \PleskX\Api\Struct
7+
{
8+
/** @var array */
9+
public $properties;
10+
11+
public function __construct($apiResponse)
12+
{
13+
$this->properties = [];
14+
15+
foreach ($apiResponse->webspace->get->result->data->{'php-settings'}->setting as $setting) {
16+
$this->properties[(string)$setting->name] = (string)$setting->value;
17+
}
18+
}
19+
}

tests/WebspaceTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ public function testGetPhysicalHostingDescriptor()
3737
$this->assertEquals('string', $ftpLoginProperty->type);
3838
}
3939

40+
public function testGetPhpSettings()
41+
{
42+
$webspace = static::_createWebspace();
43+
$info = static::$_client->webspace()->getPhpSettings('id', $webspace->id);
44+
45+
$this->assertArrayHasKey('open_basedir', $info->properties);
46+
}
47+
4048
public function testCreateWebspace()
4149
{
4250
$webspace = static::_createWebspace();

0 commit comments

Comments
 (0)