-
Notifications
You must be signed in to change notification settings - Fork 4
Sample Usage
Jake Litwicki edited this page Jun 2, 2015
·
1 revision
<?php
//use statements
use Litwicki\Bundle\ChargifyBundle\Model\Customer;
public function showCustomersAction(Request $request)
{
//check permissions and stuff here..
$handler = $this->container->get('litwicki_chargify.handler.customers');
//$customers is an array of customer objects
$customers = $handler->findAll();
//do stuff, return to twig, or return as json
}
public function newCustomerAction(Request $request)
{
//Create the Customer object
$customer = new Customer();
$customer->setFirstName('John');
$customer->setLastName('Doe');
$customer->setEmail('john.doe@gmail.com'):
$customer->setReference($customer->getEmail());
//Load the Customer Handler service
$handler = $this->container->get('litwicki_chargify.handler.customers');
//Save the customer object, and repopulate with all auto generated fields
$customer = $handler->create($customer);
}