public function CommerceInvoiceEntityController::buildContent in Commerce Invoice 7
Builds a structured array representing the entity's content.
The content built for the entity will vary depending on the $view_mode parameter.
Parameters
$entity: An entity object.
$view_mode: View mode, e.g. 'administrator'
$langcode: (optional) A language code to use for rendering. Defaults to the global content language of the current request.
Return value
The renderable array.
Overrides DrupalCommerceEntityController::buildContent
File
- includes/
commerce_invoice.controller.inc, line 254 - The controller for the invoice entity containing the CRUD operations.
Class
- CommerceInvoiceEntityController
- The controller class for invoices contains methods for the order CRUD operations. The load method is inherited from the default controller.
Code
public function buildContent($invoice, $view_mode = 'administrator', $langcode = NULL, $content = array()) {
// Load the order this invoice is attached to.
$order = commerce_order_load($invoice->order_id);
$order_build_content = entity_build_content('commerce_order', $order, $view_mode, $langcode);
foreach ($order_build_content as $field => $instance) {
if (substr($field, 0, 1) != '#' || $field == '#attached') {
$content[$field] = $instance;
}
}
$content['invoice_number'] = array(
'#markup' => theme('commerce_invoice_number', array(
'invoice_number' => $invoice->invoice_number,
'label' => t('Invoice number:'),
'invoice' => $invoice,
)),
);
$content['created'] = array(
'#markup' => theme('commerce_invoice_created', array(
'created' => format_date($invoice->created, 'short'),
'label' => t('Date:'),
'invoice' => $invoice,
)),
);
return parent::buildContent($invoice, $view_mode, $langcode, $content);
}