diff --git a/include/class-MailforwardfromQuery.php b/include/class-MailforwardfromQuery.php index 98e5642..b9db34e 100644 --- a/include/class-MailforwardfromQuery.php +++ b/include/class-MailforwardfromQuery.php @@ -1,43 +1,71 @@ . -/** - * Execute query againsts a Mailforwardfrom - */ -class MailforwardfromQuery extends DomainAPI { +// load DomainAPITrait; +class_exists( 'DomainAPI', true ); - /** - * Construct - */ - public function __construct() { - parent::__construct(); - $this->from( 'mailforwardfrom' ); - $this->equals( 'mailforwardfrom.domain_ID', 'domain.domain_ID' ); - $this->defaultClass( 'Mailforwardfrom' ); - } +trait MailforwardfromQueryTrait { /** * Filter to a specific mailforward username * * @param $username string * @return self */ public function whereMailforwardfromUsername( $username ) { return $this->whereStr( 'mailforwardfrom_username', $username ); } + public function whereMailforwardfromID( $id ) { + return $this->whereInt( $this->MAILFORWARDFROM_ID, $id ); + } + + public function whereMailforwardfrom( $mailforwardfrom ) { + return $this->whereMailforwardfromID( $mailforwardfrom->getMailforwardfromID() ); + } + +} + +/** + * Execute query againsts a Mailforwardfrom + */ +class MailforwardfromQuery extends Query { + + use MailforwardfromQueryTrait; + use DomainAPITrait; + + /** + * Univoque Domain ID column name + */ + const DOMAIN_ID = 'mailforwardfrom.domain_ID'; + + /** + * Column name of the Mailforwardfrom ID + */ + protected $MAILFORWARDFROM_ID = 'mailforwardfrom.mailforwardfrom_ID'; + + /** + * Construct + */ + public function __construct() { + parent::__construct(); + + $this->from( 'mailforwardfrom' ); + $this->defaultClass( 'Mailforwardfrom' ); + } + }