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;
12 
13 /**
14  * Encapsulates a domain-bound object.
15  *
16  * @author Niels Keurentjes <niels.keurentjes@omines.com>
17  */
18 abstract class DomainObject extends BaseObject
19 {
20     /** @var Domain */
21     private $domain;
22 
23     /**
24      * @param string $name Canonical name for the object
25      * @param Domain $domain Domain to which the object belongs
26      */
27     protected function __construct($name, Domain $domain)
28     {
29         parent::__construct($name, $domain->getContext());
30         $this->domain = $domain;
31     }
32 
33     /**
34      * Invokes a POST command on a domain object.
35      *
36      * @param string $command Command to invoke
37      * @param string $action Action to execute
38      * @param array $parameters Additional options for the command
39      * @param bool $clearCache Whether to clear the domain cache
40      * @return array Response from the API
41      */
42     protected function invokePost($command, $action, $parameters = [], $clearCache = true)
43     {
44         return $this->domain->invokePost($command, $action, $parameters, $clearCache);
45     }
46 
47     /**
48      * @return Domain
49      */
50     public function getDomain()
51     {
52         return $this->domain;
53     }
54 
55     /**
56      * @return string
57      */
58     public function getDomainName()
59     {
60         return $this->domain->getDomainName();
61     }
62 
63     /**
64      * Converts an associative array of descriptors to objects of the specified type.
65      *
66      * @param array $items
67      * @param string $class
68      * @param Domain $domain
69      * @return array
70      */
71     public static function toDomainObjectArray(array $items, $class, Domain $domain)
72     {
73         array_walk($items, function (&$value, $name) use ($class, $domain) {
74             $value = new $class($name, $domain, $value);
75         });
76         return $items;
77     }
78 }
79 
API documentation generated by ApiGen