Introduction

Last updated on
9 May 2017

Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites

This document gives a quick introduction to the architectural concepts of Ubercart Addresses 6.x-2.x and 7.x-1.x.

Architecture

The Ubercart Addresses API can be split into two parts:

  • The address book API
  • The field handler API

The address book API is used to control addresses. With it you can create, load, edit, save and delete addresses. The field handler API is used to control address fields. With this API you can register your own address fields that can be used in address edit forms and when an address is viewed (for example in the address book).

The address book API

The address book API consist of three classes:

  • The address book class: UcAddressesAddressBook
    Used to hold a list of addresses of type UcAddressesAddress and to control these addresses.
  • The address class: UcAddressesAddress
    Used in combination with the address book class; provides specific address book features, such as default addresses. Extends the class UcAddressesSchemaAddress.
  • The schema address class: UcAddressesSchemaAddress
    Used to set and get address fields registered through the field handler API.

Read more about the address book API.

The field handler API

The field handler API consist of field handlers and fields. A field handler is a class that extends UcAddressesFieldHandler and is among more used to generate the form field and to output the fields' "safe" value (a value that is safe for output, e.g. sanitized through check_plain()). A field is something that can be viewed on a page or edited in a form. Every field has a field handler. Fields and field handlers are registered through the hooks hook_uc_addresses_fields() and hook_uc_addresses_field_handlers().
Read more about the field handler API.

Other classes

The permissions class: UcAddressesPermissions

Ubercart Addresses also contains a permissions class, used to check access for viewing, editing and deleting addresses. The permissions class is not used in the address book API and the field handler API, only in the module code. If you want to use the Ubercart Addresses API in your own module, make sure you check for permissions on the appropriate places.
Read more about the permissions class.

Exception classes

Exceptions are thrown whenever code tries to use the API in a way that is not supported or when something unexpected happens. Modules using the API are encouraged to use try-catch blocks where needed to avoid the PHP fatal error "Uncaught exception". See class/Exceptions.inc (included with the module) for more information about what kind of exceptions can be thrown by Ubercart Addresses.

Help improve this page

Page status: No known problems

You can: