Created
January 25, 2015 20:02
-
-
Save bakura10/9f666d9b5f2d2742ffa1 to your computer and use it in GitHub Desktop.
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 UserRegistrationService | |
{ | |
private $em; | |
private $service1; | |
private $service2; | |
public function register(User $user, $cardToken) | |
{ | |
$this->em->transactional(function() { | |
$this->service1->create($user); | |
$this->service2->createCustomer($user, $cardToken); | |
}); | |
} | |
} |
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 UserService | |
{ | |
public function create(User $user) | |
{ | |
$this->entityManager->persist($user); | |
$this->entityManager->flush(); | |
} | |
} |
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 StripeService | |
{ | |
public function createCustomer(User $user, $cardToken) | |
{ | |
// Make the call to Stripe API, retrieve the customer ID, and save it | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment