-
-
Save meDavid/e31ff7f92734cefd32c446d5068a7403 to your computer and use it in GitHub Desktop.
Create Card Guard listener
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CreateCardGuardListener implements EventSubscriberInterface | |
{ | |
public function guardCreateCard(GuardEvent $event) { | |
/** @var CardApplication $cardApplication */ | |
$cardApplication = $event->getSubject(); | |
// By default block this transition. | |
$event->setBlocked(true); | |
// Only allow this transition if the requested limit is less then $200 or we have an approved credit limit. | |
if ($cardApplication->getRequestedCreditLimit() < 200 || $cardApplication->getRequestedCreditLimit() <= $cardApplication->getAppprovedCreditLimit()) { | |
$event->setBlocked(false); | |
} | |
} | |
/** | |
* Returns the events to which this class has subscribed. | |
* | |
* @return array | |
*/ | |
public static function getSubscribedEvents() { | |
return [ | |
'workflow.creditcard_application_flow.guard.create_card' => array('guardCreateCard'), | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 10 in the example should be $200 in the comment to match line 11 of the code.