Skip to content

Instantly share code, notes, and snippets.

@bakura10
Created January 25, 2015 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bakura10/9f666d9b5f2d2742ffa1 to your computer and use it in GitHub Desktop.
Save bakura10/9f666d9b5f2d2742ffa1 to your computer and use it in GitHub Desktop.
<?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);
});
}
}
<?php
class UserService
{
public function create(User $user)
{
$this->entityManager->persist($user);
$this->entityManager->flush();
}
}
<?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