Skip to content
Code-Schnipsel Gruppen Projekte
Commit efa39396 erstellt von Patrick Müller's avatar Patrick Müller
Dateien durchsuchen

refactor: adjustments for quiqqer/verification API

Übergeordneter 5cf235e5
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
......@@ -2,7 +2,6 @@
namespace QUI\Memberships\Users;
use QUI\Verification\VerificationInterface;
use QUI\Memberships\Users\Handler as MembershipUsersHandler;
use QUI\Verification\Verifier;
use QUI;
......@@ -12,45 +11,17 @@
*
* Verification process for abortion of MembershipUser cancellation by frontend user
*/
class AbortCancelVerification implements VerificationInterface
class AbortCancelVerification extends QUI\Verification\AbstractVerification
{
/**
* Verification identifier
*
* @var string
*/
protected $identifier = null;
/**
* CancelVerification constructor.
*
* @param int $membershipUserId
*/
public function __construct($membershipUserId)
{
$this->identifier = $membershipUserId;
}
/**
* Get a unique identifier that identifies this Verification
*
* @return string
*/
public function getIdentifier()
{
return $this->identifier;
}
/**
* Get the duration of a Verification (minutes)
*
* @param string $identifier - Unique Verification identifier
* @return int|false - duration in minutes;
* if this method returns false use the module setting default value
*/
public static function getValidDuration($identifier)
public function getValidDuration()
{
$MembershipUser = MembershipUsersHandler::getInstance()->getChild((int)$identifier);
$MembershipUser = MembershipUsersHandler::getInstance()->getChild($this->getIdentifier());
$endDate = $MembershipUser->getAttribute('endDate');
$endDate = strtotime($endDate) / 60; // minutes
$now = time() / 60; // minutes
......@@ -61,23 +32,21 @@ public static function getValidDuration($identifier)
/**
* Execute this method on successful verification
*
* @param string $identifier - Unique Verification identifier
* @return void
*/
public static function onSuccess($identifier)
public function onSuccess()
{
/** @var MembershipUser $MembershipUser */
$MembershipUser = MembershipUsersHandler::getInstance()->getChild((int)$identifier);
$MembershipUser = MembershipUsersHandler::getInstance()->getChild($this->getIdentifier());
$MembershipUser->confirmAbortCancel();
}
/**
* Execute this method on unsuccessful verification
*
* @param string $identifier - Unique Verification identifier
* @return void
*/
public static function onError($identifier)
public function onError()
{
// nothing
}
......@@ -85,26 +54,27 @@ public static function onError($identifier)
/**
* This message is displayed to the user on successful verification
*
* @param string $identifier - Unique Verification identifier
* @return string
*/
public static function getSuccessMessage($identifier)
public function getSuccessMessage()
{
/** @var MembershipUser $MembershipUser */
$MembershipUser = MembershipUsersHandler::getInstance()->getChild((int)$identifier);
$MembershipUser = MembershipUsersHandler::getInstance()->getChild($this->getIdentifier());
$data = $MembershipUser->getFrontendViewData();
if ($MembershipUser->getMembership()->isAutoExtend()) {
$msg = QUI::getLocale()->get(
'quiqqer/memberships',
'verification.abortcancel.success.autoExtend', array(
'verification.abortcancel.success.autoExtend',
array(
'endDate' => $data['endDate']
)
);
} else {
$msg = QUI::getLocale()->get(
'quiqqer/memberships',
'verification.abortcancel.success.noAutoExtend', array(
'verification.abortcancel.success.noAutoExtend',
array(
'endDate' => $data['endDate']
)
);
......@@ -116,11 +86,10 @@ public static function getSuccessMessage($identifier)
/**
* This message is displayed to the user on unsuccessful verification
*
* @param string $identifier - Unique Verification identifier
* @param string $reason - The reason for the error (see \QUI\Verification\Verifier::REASON_)
* @return string
*/
public static function getErrorMessage($identifier, $reason)
public function getErrorMessage($reason)
{
switch ($reason) {
case Verifier::ERROR_REASON_EXPIRED:
......@@ -150,10 +119,9 @@ public static function getErrorMessage($identifier, $reason)
/**
* Automatically redirect the user to this URL on successful verification
*
* @param string $identifier - Unique Verification identifier
* @return string|false - If this method returns false, no redirection takes place
*/
public static function getOnSuccessRedirectUrl($identifier)
public function getOnSuccessRedirectUrl()
{
return false;
}
......@@ -163,10 +131,9 @@ public static function getOnSuccessRedirectUrl($identifier)
*
* Hint: This requires that an active Verification with the given identifier exists!
*
* @param string $identifier - Unique Verification identifier
* @return string|false - If this method returns false, no redirection takes place
*/
public static function getOnErrorRedirectUrl($identifier)
public function getOnErrorRedirectUrl()
{
return false;
}
......
......@@ -2,7 +2,6 @@
namespace QUI\Memberships\Users;
use QUI\Verification\VerificationInterface;
use QUI\Memberships\Users\Handler as MembershipUsersHandler;
use QUI\Verification\Verifier;
use QUI;
......@@ -12,43 +11,15 @@
*
* Verification process for MembershipUser cancellation by frontend user
*/
class CancelVerification implements VerificationInterface
class CancelVerification extends QUI\Verification\AbstractVerification
{
/**
* Verification identifier
*
* @var string
*/
protected $identifier = null;
/**
* CancelVerification constructor.
*
* @param int $membershipUserId
*/
public function __construct($membershipUserId)
{
$this->identifier = $membershipUserId;
}
/**
* Get a unique identifier that identifies this Verification
*
* @return string
*/
public function getIdentifier()
{
return $this->identifier;
}
/**
* Get the duration of a Verification (minutes)
*
* @param string $identifier - Unique Verification identifier
* @return int|false - duration in minutes;
* if this method returns false use the module setting default value
*/
public static function getValidDuration($identifier)
public function getValidDuration()
{
return (int)MembershipUsersHandler::getSetting('cancelDuration');
}
......@@ -56,23 +27,21 @@ public static function getValidDuration($identifier)
/**
* Execute this method on successful verification
*
* @param string $identifier - Unique Verification identifier
* @return void
*/
public static function onSuccess($identifier)
public function onSuccess()
{
/** @var MembershipUser $MembershipUser */
$MembershipUser = MembershipUsersHandler::getInstance()->getChild((int)$identifier);
$MembershipUser = MembershipUsersHandler::getInstance()->getChild($this->getIdentifier());
$MembershipUser->confirmManualCancel();
}
/**
* Execute this method on unsuccessful verification
*
* @param string $identifier - Unique Verification identifier
* @return void
*/
public static function onError($identifier)
public function onError()
{
// nothing
}
......@@ -80,10 +49,9 @@ public static function onError($identifier)
/**
* This message is displayed to the user on successful verification
*
* @param string $identifier - Unique Verification identifier
* @return string
*/
public static function getSuccessMessage($identifier)
public function getSuccessMessage()
{
return QUI::getLocale()->get(
'quiqqer/memberships',
......@@ -94,11 +62,10 @@ public static function getSuccessMessage($identifier)
/**
* This message is displayed to the user on unsuccessful verification
*
* @param string $identifier - Unique Verification identifier
* @param string $reason - The reason for the error (see \QUI\Verification\Verifier::REASON_)
* @return string
*/
public static function getErrorMessage($identifier, $reason)
public function getErrorMessage($reason)
{
switch ($reason) {
case Verifier::ERROR_REASON_EXPIRED:
......@@ -128,10 +95,9 @@ public static function getErrorMessage($identifier, $reason)
/**
* Automatically redirect the user to this URL on successful verification
*
* @param string $identifier - Unique Verification identifier
* @return string|false - If this method returns false, no redirection takes place
*/
public static function getOnSuccessRedirectUrl($identifier)
public function getOnSuccessRedirectUrl()
{
return false;
}
......@@ -141,10 +107,9 @@ public static function getOnSuccessRedirectUrl($identifier)
*
* Hint: This requires that an active Verification with the given identifier exists!
*
* @param string $identifier - Unique Verification identifier
* @return string|false - If this method returns false, no redirection takes place
*/
public static function getOnErrorRedirectUrl($identifier)
public function getOnErrorRedirectUrl()
{
return false;
}
......
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren