Skip to content

Commit 115e700

Browse files
author
dpfaffenbauer
committed
implement SiteAlias Operator and struct
1 parent 5d778aa commit 115e700

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

src/PleskX/Api/Operator/SiteAlias.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,33 @@
33

44
namespace PleskX\Api\Operator;
55

6+
use PleskX\Api\Struct\SiteAlias as Struct;
7+
68
class SiteAlias extends \PleskX\Api\Operator
79
{
10+
/**
11+
* @param array $properties
12+
* @param array $preferences
13+
* @return Struct\Info
14+
*/
15+
public function create(array $properties, array $preferences = [])
16+
{
17+
$packet = $this->_client->getPacket();
18+
$info = $packet->addChild($this->_wrapperTag)->addChild('create');
19+
20+
if (count($preferences) > 0) {
21+
$prefs = $info->addChild('pref');
22+
23+
foreach ($preferences as $key => $value) {
24+
$prefs->addChild($key, is_bool($value) ? ($value ? 1 : 0) : $value);
25+
}
26+
}
27+
28+
$info->addChild('site-id', $properties['site-id']);
29+
$info->addChild('name', $properties['name']);
30+
31+
$response = $this->_client->request($packet);
32+
return new Struct\Info($response);
33+
}
834

935
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
// Copyright 1999-2016. Parallels IP Holdings GmbH.
3+
4+
namespace PleskX\Api\Struct\SiteAlias;
5+
6+
class Info extends \PleskX\Api\Struct
7+
{
8+
/** @var string */
9+
public $status;
10+
11+
/** @var integer */
12+
public $id;
13+
14+
public function __construct($apiResponse)
15+
{
16+
$this->_initScalarProperties($apiResponse, [
17+
'id',
18+
'status',
19+
]);
20+
}
21+
}

0 commit comments

Comments
 (0)