Skip to content

Instantly share code, notes, and snippets.

@totten

totten/ex.php Secret

Last active Aug 29, 2015
Embed
What would you like to do?
Making a broad but concrete+simple interface to event registration + contributions + memberships. A few simplifications (which seem acceptable): there's no need to create arbitrary line items; line-items are only created in the context of a participant/membership/contribution. At most, you might tweak the line-item that's autogenerated.
<?php
interface CiviInvoice {
/**
* Add details about a registration which a constituent would like to purchase.
*
* @param Participant $participant
* The event-registration which would be purchased.
* @return LineItem
* A new line item which represents the would-be registration.
*/
function addParticipant($participant);
/**
* @param Contribution $contribution
* @return LineItem
*/
function addContribution($contribution);
/**
* @param Membership $membership
* @return LineItem
*/
function addMembership($membership);
/**
* @param Payment $payment
*/
function addPayment($payment);
/**
* @return array<LineItem>
*/
function getLineItems();
/**
* @return LineItem
*/
function getLineItem(int $lineItemID);
/**
* @return Participant|Membership|Contribution
*/
function getLineItemTarget($int $lineItemID);
function getPayments();
function removeLineItem(int $lineItemID)
}
// Usage
$ci = new CiviInvoice();
$ci->addMembership(...membership1...);
$ci->addMembership(...membershp2...);
$ci->addContribution(...);
$entityManager->persist($ci);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.