File: //usr/local/mailchannels/hooks/PostCpApiPark.php
<?php
namespace MailChannels;
class PostCpApiPark extends PostAccountsCreate {
public function execute($hookData) {
if ($this->inboundEnabled()) {
if ($this->isSuccessfulCpanelResult($hookData)) {
if (isset($hookData['data']['args']) && isset($hookData['data']['args']['domain'])) {
if ($this->inboundConfig->isAutomaticDomainProtectionEnabled()
&& $this->inboundConfig->processParkedAndAddonDomains()) {
$domain = $hookData['data']['args']['domain'];
try {
return $this->inboundProvision($domain);
} catch (\Exception $e) {
$errorMessage = $e->getTraceAsString();
return array(false, "error provisioning domain $domain: $errorMessage");
}
}
return array(true, "action not taken; automatic provisioning and/or parked and/or addon domain processing is not set");
}
return array(false, "could not find the domain in the hook data");
}
return array(false, "missing hook data or the api function failed");
}
return array(true, "action not taken; inbound not enabled");
}
public static function category() {
return 'Cpanel';
}
public static function event() {
return 'Api2::Park::park';
}
public static function stage() {
return 'post';
}
}