/** * Construct the object. * * @param string $name Username of the account * @param UserContext $context The context managing this object * @param mixed|null $config An optional preloaded configuration */ public function __construct($name, UserContext $context, $config = null) { parent::__construct($name, $context); if (isset($config)) { $this->setCache(self::CACHE_CONFIG, $config); } }
/** * Construct the object. * * @param string $name The domain name * @param UserContext $context The owning user context * @param string|array $config The basic config string as returned by CMD_API_ADDITIONAL_DOMAINS */ public function __construct($name, UserContext $context, $config) { parent::__construct($name, $context); // Unpack domain config $data = is_array($config) ? $config : \GuzzleHttp\Psr7\parse_query($config); $this->domainName = $data['domain']; // Determine owner if ($data['username'] === $context->getUsername()) { $this->owner = $context->getContextUser(); } else { throw new DirectAdminException('Could not determine relationship between context user and domain'); } // Parse plain options $bandwidths = array_map('trim', explode('/', $data['bandwidth'])); $this->bandwidthUsed = floatval($bandwidths[0]); $this->bandwidthLimit = ctype_alpha($bandwidths[1]) ? null : floatval($bandwidths[1]); $this->diskUsage = floatval($data['quota']); $this->aliases = array_filter(explode('|', $data['alias_pointers'])); $this->pointers = array_filter(explode('|', $data['pointers'])); }
/** * @param string $host * @param Database $database */ public function __construct($host, Database $database) { parent::__construct($host, $database->getContext()); $this->database = $database; }
/** * Database constructor. * * @param string $name Name of the database * @param User $owner Database owner * @param UserContext $context Context within which the object is valid */ public function __construct($name, User $owner, UserContext $context) { parent::__construct($name, $context); $this->owner = $owner; $this->databaseName = $this->owner->getUsername() . '_' . $this->getName(); }