Overview
  • Namespace
  • Class

Namespaces

  • Omines
    • DirectAdmin
      • Context
      • Objects
        • Database
        • Domains
        • Email
        • Users
      • Utility

Classes

  • Omines\DirectAdmin\Context\AdminContext
  • Omines\DirectAdmin\Context\BaseContext
  • Omines\DirectAdmin\Context\ResellerContext
  • Omines\DirectAdmin\Context\UserContext
  • Omines\DirectAdmin\DirectAdmin
  • Omines\DirectAdmin\Objects\BaseObject
  • Omines\DirectAdmin\Objects\Database
  • Omines\DirectAdmin\Objects\Database\AccessHost
  • Omines\DirectAdmin\Objects\Domain
  • Omines\DirectAdmin\Objects\DomainObject
  • Omines\DirectAdmin\Objects\Domains\Subdomain
  • Omines\DirectAdmin\Objects\Email\Forwarder
  • Omines\DirectAdmin\Objects\Email\Mailbox
  • Omines\DirectAdmin\Objects\Email\MailObject
  • Omines\DirectAdmin\Objects\Users\Admin
  • Omines\DirectAdmin\Objects\Users\Reseller
  • Omines\DirectAdmin\Objects\Users\User
  • Omines\DirectAdmin\Utility\Conversion

Exceptions

  • Omines\DirectAdmin\DirectAdminException
 1 <?php
 2 
 3 /*
 4  * DirectAdmin API Client
 5  * (c) Omines Internetbureau B.V. - https://omines.nl/
 6  *
 7  * For the full copyright and license information, please view the LICENSE
 8  * file that was distributed with this source code.
 9  */
10 
11 namespace Omines\DirectAdmin\Objects\Database;
12 
13 use Omines\DirectAdmin\Objects\Database;
14 use Omines\DirectAdmin\Objects\BaseObject;
15 
16 /**
17  * AccessHost.
18  */
19 class AccessHost extends BaseObject
20 {
21     /** @var Database $database */
22     protected $database;
23 
24     /**
25      * @param string   $host
26      * @param Database $database
27      */
28     public function __construct($host, Database $database)
29     {
30         parent::__construct($host, $database->getContext());
31         $this->database = $database;
32     }
33 
34     /**
35      * @param Database $database
36      * @param string   $host
37      * @return AccessHost
38      */
39     public static function create(Database $database, $host)
40     {
41         $database->getContext()->invokeApiPost('DATABASES', [
42             'action' => 'accesshosts',
43             'create' => 'yes',
44             'db' => $database->getDatabaseName(),
45             'host' => $host,
46         ]);
47         return new self($host, $database);
48     }
49 
50     /**
51      * Deletes the access host.
52      */
53     public function delete()
54     {
55         $this->getContext()->invokeApiPost('DATABASES', [
56             'action' => 'accesshosts',
57             'delete' => 'yes',
58             'db' => $this->database->getDatabaseName(),
59             'select0' => $this->getName(),
60         ]);
61         $this->database->clearCache();
62     }
63 
64     /**
65      * @return string
66      */
67     public function getHost()
68     {
69         return $this->getName();
70     }
71 
72     /**
73      * @return string
74      */
75     public function __toString()
76     {
77         return $this->getHost();
78     }
79 }
80 
API documentation generated by ApiGen