forked from virtuozzo/OnApp-PHP-Wrapper-External
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Factory.php
54 lines (49 loc) · 1.46 KB
/
Factory.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* API Factory Wrapper for OnApp
*
* This API provides an interface to onapp.com allowing common virtual machine
* and account management tasks
*
* @category Factory
* @package OnApp
* @author Andrew Yatskovets
* @copyright © 2011 OnApp
* @link http://www.onapp.com/
*/
class OnApp_Factory extends OnApp {
/**
* Object constructor
*
* @param string $hostname
* @param string $username
* @param string $password
* @param string|null $proxy
*/
public function __construct( $hostname, $username, $password, $proxy = null ) {
parent::__construct();
$this->auth( $hostname, $username, $password );
//todo ??? constructor should return instance instead of boolean value
//return $this->_is_auth;
}
/**
* Craft new object
*
* @param string $name class name
* @param bool $debug flag for debug mode
*
* @return object instance of class
*/
public function factory( $name, $debug = false ) {
$class_name = 'OnApp_' . $name;
$result = new $class_name();
$result->logger->setDebug( $debug );
$result->setOption( ONAPP_OPTION_DEBUG_MODE, $debug );
$result->logger->setTimezone();
$result->version = $this->getAPIVersion();
$result->options = $this->options;
$result->_ch = $this->_ch;
$result->initFields( $this->getAPIVersion() );
return $result;
}
}