Difference between revisions of "API/HookManager"

From aMember Pro Documentation
Jump to: navigation, search
Line 54: Line 54:
 
class Am_Event
 
class Am_Event
 
{
 
{
     /**
+
     /** Called after db upgrade */
    * Called after db upgrade
+
    *
+
    * * string version
+
    *
+
    */
+
 
     const DB_UPGRADE = 'dbUpgrade';
 
     const DB_UPGRADE = 'dbUpgrade';
 
 
     /** Called every hour by cronjob */
 
     /** Called every hour by cronjob */
 
     const HOURLY = 'hourly';
 
     const HOURLY = 'hourly';
Line 77: Line 71:
 
     *  
 
     *  
 
     *  {@link Invoice Invoice}  
 
     *  {@link Invoice Invoice}  
    *  : invoice
 
 
     */
 
     */
 
     const INVOICE_STARTED = 'invoiceStarted';
 
     const INVOICE_STARTED = 'invoiceStarted';
Line 287: Line 280:
 
     */
 
     */
 
     const SUBSCRIPTION_REMOVED = 'subscriptionRemoved';
 
     const SUBSCRIPTION_REMOVED = 'subscriptionRemoved';
   
 
 
     /**
 
     /**
 
     * Access record inserted
 
     * Access record inserted
Line 307: Line 299:
 
     */
 
     */
 
     const ACCESS_AFTER_DELETE = 'accessAfterDelete';
 
     const ACCESS_AFTER_DELETE = 'accessAfterDelete';
 
 
     /**
 
     /**
 
     * Called before invoice insertion
 
     * Called before invoice insertion
Line 333: Line 324:
 
     */
 
     */
 
     const INVOICE_AFTER_CANCEL= 'invoiceAfterCancel';
 
     const INVOICE_AFTER_CANCEL= 'invoiceAfterCancel';
 
   
 
 
     /**
 
     /**
 
     * Called after invoice payment refund(or chargeback)
 
     * Called after invoice payment refund(or chargeback)
 
     * <li>{@link InvoiceRefund} refund</li>
 
     * <li>{@link InvoiceRefund} refund</li>
 
     */
 
     */
     const INVOICE_PAYMENT_REFUND= 'invoicePaymentRefund';
+
     const INVOICE_PAYMENT_REFUND = 'invoicePaymentRefund';
   
+
   
+
 
     /**
 
     /**
 
     * Called to check for username uniquiness
 
     * Called to check for username uniquiness
Line 699: Line 686:
 
     */
 
     */
 
     const GET_STRONG_PASSWORD_REGEX = 'getStrongPasswordRegex';
 
     const GET_STRONG_PASSWORD_REGEX = 'getStrongPasswordRegex';
   
 
    /**
 
    * Ability to change affiliate redirect link, for example to add custom tracking params
 
    * @param User $aff
 
    * @link Am_Event::getReturn()
 
    * @link Am_Event::setReturn()
 
    */
 
    const GET_AFF_REDIRECT_LINK = 'getAffRedirectLink';
 
 
     ....
 
     ....
 
}
 
}
 
</source>
 
</source>

Revision as of 01:17, 4 August 2014

aMember Pro provides a flexible mechanism to change or add new behaviour to existing actions. It utilises the well-known [Observer] programming pattern.

To wait for an event the code must set up a "hook". Then, on some occasion, the core code or add-on code(!) sends Events (instances of Am_Event class or successors) to all interested parties. Parties handle events by executing pieces of code and, for some events, by adding return values to an event object. Then, the event object is returned to the called core code where it can be inspected and used. It is lengthy to explain, but easy to understand by example:

Setting Hooks. Method 1 - from any part of code

<?php
// you can enter this example to am/application/configs/site.php
// define handlers for an event
function my_custom_function1(Am_Event $event) { $event->addReturn($event->getX() + 1); }
function my_custom_function2(Am_Event $event) { $event->addReturn($event->getX() + 2); }
 
// setup hooks
Am_Di::getInstance()->hook->
   ->add('myCustomEvent', 'my_custom_function1')
   ->add('myCustomEvent', 'my_custom_function2');
 
// now raise the event with variable x = 5 and get returned event object
$event = Am_Di::getInstance()->hook->call('myCustomEvent', array('x' => 5));
 
// now check the return. it will be array(5+1, 5+2) == array(6, 7)
print_rr($event->getReturn());

Setting Hooks. Method 2 - from a plugin or a module

// within file am/application/default/plugins/misc/my.php
class MyPlugin extends Am_Plugin
{
    function onMyCustomEvent(Am_Event $event) 
    { 
        $event->addReturn($event->getX() + 1); 
    }
}

You do not need to set up a hook in the plugin explicitly. Just add a plugin named onHookname() to the plugin class, and, if the plugin is enabled and configured, the hook will be set up automatically.

Example continues: within am/application/configs/site.php

// now raise the event with variable x = 5 and get returned event object
$event = Am_Di::getInstance()->hook->call('myCustomEvent', array('x' => 5));
 
// now check the return. it will be array(5+1, 5+2) == array(6, 7)
print_rr($event->getReturn());

Available Events

You can check for available core events in class Am_Event. There are many constants defined for events. Also, please note that different events may receive difference event objects (all derived for Am_Event parent). For example, event userBeforeInsert will receive object of Am_Event_UserBeforeInsert as parameter.

Here is a list of currently available events:

class Am_Event
{
    /** Called after db upgrade */
    const DB_UPGRADE = 'dbUpgrade';
    /** Called every hour by cronjob */
    const HOURLY = 'hourly';
    /** Called every day by cronjob */
    const DAILY  = 'daily';
    /** Called every week by cronjob */
    const WEEKLY  = 'weekly';
    /** Called 1-st day of month by cronjob */
    const MONTHLY  = 'monthly';
    /** Called 1-st day of year by cronjob */
    const YEARLY  = 'yearly';
    /** Called when aMember API stack initialization is finished */
    const INIT_FINISHED  = 'initFinished';
    /** Called when an invoice becomes active_recuirring or paid, or free trial is started 
     * 
     *  {@link Invoice Invoice} 
     */
    const INVOICE_STARTED = 'invoiceStarted';
 
    /**
     * Called when invoice status is changed
     *  
     * Parameters:
     *  * {@link Invoice Invoice} invoice</li>
     *  * int status - new status of invoice</li>
     *  * int oldStatus - previous status of invoice</li>
     * 
     */
    const INVOICE_STATUS_CHANGE = 'invoiceStatusChange';
 
    /**
     * Called just before customer record deletion.
     * By triggering exception from the hook, deletion may be stopped
     * 
     *  * {@link User User} user
     */
    const USER_BEFORE_DELETE = 'userBeforeDelete';
    /**
     * Called after customer record deletion.
     * 
     *  * {@link User User} user
     */
    const USER_AFTER_DELETE = 'userAfterDelete';
    /**
     * Called before user record is inserted into table
     * 
     *  * {@link User User} user
     */
    const USER_BEFORE_INSERT = 'userBeforeInsert';
    /**
     * Called after user record is inserted into table
     * 
     *  * {@link User User} user
     */
    const USER_AFTER_INSERT = 'userAfterInsert';
    /**
     * Called before user record is updated in database
     * 
     *  * {@link User User} user
     */
    const USER_BEFORE_UPDATE = 'userBeforeUpdate';
    /**
     * Called after user record is updated in database
     * 
     *  * {@link User User} user
     */
    const USER_AFTER_UPDATE = 'userAfterUpdate';
    /**
     * Called once value of $user->unsubscribe field is changed
     * 
     *  <li>{@link User User} user</li>
     *  <li>int unsubscribed - new value of 'unsubscribed' field</li>
     * 
     */
    const USER_UNSUBSCRIBED_CHANGED = 'userUnsubscribedChanged';
    /**
     * Called after product record deletion.
     *
     *  * {@link Product} product
     */
    const PRODUCT_AFTER_DELETE = 'productAfterDelete';
    /**
     * Called just before coupon update
     *
     * @param Coupon $coupon
     * @param Coupon $old
     */
    const COUPON_BEFORE_UPDATE = 'couponBeforeUpdate';
 
    /**
     * Called when customer password is changed, plain-text password
     * is available in this hook
     * 
     *  * {@link User User} user
     *  * string password - plain-text password
     * 
     *  Event Class: Am_Event_SetPassword
     */
    const SET_PASSWORD = 'setPassword';
    /** User (or affiliate) record is added after submitting signup form - before payment */
    const SIGNUP_USER_ADDED = 'signupUserAdded';
    /** User record is added after submitting signup form - before payment */
    const SIGNUP_AFF_ADDED = 'signupAffAdded';
    /** User record is updated after submitting signup form - before payment */
    const SIGNUP_USER_UPDATED  = 'signupUserUpdated';
 
    /** User record is updated after submitting profile form*/
    const PROFILE_USER_UPDATED  = 'profileUserUpdated';
 
    /** Called just before payment record insered into database. Is not called for free subscriptions */
    const PAYMENT_BEFORE_INSERT = 'paymentBeforeInsert';
    /** Payment record insered into database. Is not called for free subscriptions */
    const PAYMENT_AFTER_INSERT = 'paymentAfterInsert';
    /** Payment record with access insered into database. Is not called for free subscriptions. Required to get access records. */
    const PAYMENT_WITH_ACCESS_AFTER_INSERT = 'paymentWithAccessAfterInsert';
 
    /** Return array of objects to calculate invoice. 
     * 
     * @link Invoice::getCalculators() 
     * @link Am_Event::getReturn()
     * @link Am_Event::setReturn()
     * <code>
     * function onInvoiceGetCalculators(Am_Event $event)
     * {
     *      $calculators = $event->getReturn();
     *      $calculators[] = new MyInvoiceCalculator($event->getInvoice());
     *      $event->setReturn($calculators);
     * }
     * </code>
     */
    const INVOICE_GET_CALCULATORS = 'invoiceGetCalculators';
    /** 
     * Called when invoice calculation is finished
     * @var Invoice invoice
     */
    const INVOICE_CALCULATE = 'invoiceCalculate';
    /**
     * Check if we can authenticate user by third-party database 
     * @see Am_Event_AuthCheckLoggedIn
     */
    const AUTH_CHECK_LOGGED_IN = 'authCheckLoggedIn';
    /**
     * Called upon succesful user login 
     * @see Am_Event_AuthAfterLogin
     */
    const AUTH_AFTER_LOGIN = 'authAfterLogin';
    /**
     * If user login was failed through aMember users database,
     * this event allows to create aMember account on-fly and 
     * login user
     * @see Am_Event_AuthTryLogin
     */
    const AUTH_TRY_LOGIN = 'authTryLogin';
    /**
     * Called on user logout
     * @see Am_Event_AuthAfterLogout
     */
    const AUTH_AFTER_LOGOUT = 'authAfterLogout';
    /**
     * Called on user check during authentification
     * You can reject valid user authentification
     * by some creteria
     *
     * <code>
     *  $user = $event->getUser();
     *  $event->setResult(new Am_Auth_Result(-100, ___('You can not login becouse of...')));
     *  $event->stop();
     * </code>
     *
     * @param User $user
     * @link Am_Event::getReturn()
     * @link Am_Event::setReturn()
     * @link Am_Event::stop()
     */
    const AUTH_CHECK_USER = 'authCheckUser';
    /**
     * Called on choose redirect url after login
     *
     * @param User $user
     * @link Am_Event::getReturn()
     * @link Am_Event::setReturn()
     */
    const AUTH_GET_OK_REDIRECT = 'authGetOkRedirect';
    /**
     * Called to get list of member links
     * @see Am_Event::addReturn() 
     */
    const GET_MEMBER_LINKS = 'getMemberLinks';
    /**
     * Called to get list of member links at left
     * @see Am_Event::addReturn() 
     */
    const GET_LEFT_MEMBER_LINKS = 'getLeftMemberLinks';
 
    /**
     * Called when user receives a subscription to product 
     * he was not subscribed earlier
     * @see Am_Event_SubscriptionAdded
     */
    const SUBSCRIPTION_ADDED = 'subscriptionAdded';
    /**
     * Called when user subscription access is deleted
     * @see Am_Event_SubscriptionDeleted
     */
    const SUBSCRIPTION_DELETED = 'subscriptionDeleted';
    /**
     * Called once for multiple changes, provides list of
     * added and deleted products 
     * @see Am_Event::SUBSCRIPTION_ADDED
     * @see Am_Event::SUBSCRIPTION_DELETED
     * @see Am_Event_SubscriptionChanged
     */
    const SUBSCRIPTION_CHANGED = 'subscriptionChanged';
    /**
     * Called when user information is changed
     * @see Am_Event_SubscriptionUpdated
     * @deprecated use Am_Event::USER_AFTER_UPDATE instead
     */
    const SUBSCRIPTION_UPDATED = 'subscriptionUpdated';
    /**
     * Called when user record is deleted
     * @see Am_Event_SubscriptionRemoved
     * @deprecated use Am_Event::USER_AFTER_DELETE instead
     */
    const SUBSCRIPTION_REMOVED = 'subscriptionRemoved';
    /**
     * Access record inserted
     * NOTE - record may be in not-active state - check dates
     * <li>{@link Access} access</li>
     * @see Am_Event::SUBSCRIPTION_ADDED
     */
    const ACCESS_AFTER_INSERT = 'accessAfterInsert';
    /**
     * Access record updated
     * <li>{@link Access} access</li>
     * @var Access old - record before changes
     */
    const ACCESS_AFTER_UPDATE = 'accessAfterUpdate';
    /**
     * Access record deleted
     * NOTE - record may be in not-active state - check dates
     * <li>{@link Access} access</li>
     */
    const ACCESS_AFTER_DELETE = 'accessAfterDelete';
    /**
     * Called before invoice insertion
     * <li>{@link Invoice} invoice</li>
     */
    const INVOICE_BEFORE_INSERT = 'invoiceBeforeInsert';
    /**
     * Called after invoice insertion
     * <li>{@link Invoice} invoice</li>
     */
    const INVOICE_AFTER_INSERT = 'invoiceAfterInsert';
    /**
     * Called before invoice deletion
     * <li>{@link Invoice} invoice</li>
     */
    const INVOICE_BEFORE_DELETE = 'invoiceBeforeDelete';
    /**
     * Called after invoice deletion
     * <li>{@link Invoice} invoice</li>
     */
    const INVOICE_AFTER_DELETE = 'invoiceAfterDelete';
    /**
     * Called after invoice cancelation
     * <li>{@link Invoice} invoice</li>
     */
    const INVOICE_AFTER_CANCEL= 'invoiceAfterCancel';
    /**
     * Called after invoice payment refund(or chargeback)
     * <li>{@link InvoiceRefund} refund</li>
     */
    const INVOICE_PAYMENT_REFUND = 'invoicePaymentRefund';
    /**
     * Called to check for username uniquiness
     * @see Am_Event_CheckUniqLogin
     */
    const CHECK_UNIQ_LOGIN = 'checkUniqLogin';
    /**
     * Called to check for e-mail uniquiness
     * @see Am_Event_CheckUniqEmail
     */
    const CHECK_UNIQ_EMAIL = 'checkUniqEmail';
    /**
     * Called to validate signup and profile form before processing
     * @see Am_Event_ValidateSavedForm
     */
    const VALIDATE_SAVED_FORM = 'validateSavedForm';
    /**
     * This hook is executed in global PHP scope to include external libraries
     * for example it is used by WP plugin to include WP API Stack
     */
    const GLOBAL_INCLUDES = 'globalIncludes';
    /**
     * This hook is executed after {@link Am_Event::GLOBAL_INCLUDES} is finished
     */
    const GLOBAL_INCLUDES_FINISHED = 'globalIncludesFinished';
    /**
     * This hook is called from admin-rebuild-db controller 
     * it may be used to add new items into "rebuild" UI
     * @see Am_Event_Rebuild
     */
    const REBUILD = 'rebuild';
    /** Called to get exclusions for aMember database backup
     *  If your plugin has a table that must not be backed up, 
     *  call $event->addReturn('tablewithoutprefix') on this hook */
    const SKIP_BACKUP = 'skipBackup';
    /**
     * Mutliple GRID EVENTS are available for product form  
     */
    const PRODUCT_FORM = 'productForm';
    /**
     * Called to create setup forms
     * @see Am_Event_SetupForms
     */
    const SETUP_FORMS = 'setupForms';
    /**
     * Called to collect Email Template Types
     * <li>{@link Am_Mail_TemplateTypes}</li>
     */
    const SETUP_EMAIL_TEMPLATE_TYPES = 'setupEmailTemplateTypes';
    /**
     * Called to collect common tag sets or alter existing
     *
     * @link Am_Mail_TemplateTypes
     * @link Am_Event::getReturn()
     * @link Am_Event::setReturn()
     */
    const EMAIL_TEMPLATE_TAG_SETS = 'emailTemplateTagSets';
    /**
     * Called on the thanks page
     * 
     * <li>{@link Invoice} invoice (may be null)</li>
     * <li><i>ThanksController</i> controller</li>
     */
    const THANKS_PAGE = 'thanksPage';
    /**
     * Get list of avaialable admin permissions 
     */
    const GET_PERMISSIONS_LIST = 'getPermissionsList';
    /**
     * Get list of API controllers => permissions
     */
    const GET_API_CONTROLLERS = 'getApiControllers';
    /**
     * Check permissions for remote API call
     * call $event->addReturn(true); to allow access WITHOUT any checks
     * throw exception to deny access
     */
    const API_CHECK_PERMISSIONS = 'apiCheckPermissions';
    /**
     * Get list of avaialable file upload prefixes
     */
    const GET_UPLOAD_PREFIX_LIST = 'getUploadPrefixList';
    /**
     * Get list of avaialable signup form types
     */
    const SAVED_FORM_TYPES = 'savedFormTypes';
    /**
     * Ability to chage list of bricks for form via hooks
     *
     * list of bricks can be modified depends on currently logged in user
     * and his subscription's status
     *
     * @param enum(signup, cart, profile...) $type
     * @param string $code
     * @param SavedForm $savedForm
     * @link Am_Event::getReturn()
     * @link Am_Event::setReturn()
     */
    const SAVED_FORM_GET_BRICKS = 'savedFormGetBricks';
 
    /**
     * @param string $code
     */
    const SIGNUP_STATE_SAVE = 'signupStateSave';
    const SIGNUP_STATE_LOAD = 'signupStateLoad';
 
    /**
     * Add new pages into existing "pageable" controllers like AdminContentController
     */
    const INIT_CONTROLLER_PAGES = 'initControllerPages';
    /**
     * Load available saved form bricks 
     */
    const LOAD_BRICKS = 'loadBricks';
    /**
     * Called on admin menu construction 
     * <li>{@link Am_Navigation_Admin} menu</li>
     */
    const ADMIN_MENU = 'adminMenu';
    /**
     * Called on admin dashboard to display warnings
     */
    const ADMIN_WARNINGS = 'adminWarnings';
    /**
     * Called on user menu construction
     * <li>{@link Am_Navigation_User} menu</li>
     */
    const USER_MENU = 'userMenu';
    /**
     * Called on admin user view pages to create tabs
     * @see Am_Event_UserTabs
     */
    const USER_TABS = 'userTabs';
    /**
     * Called to get available admin user search conditions 
     */
    const USER_SEARCH_CONDITIONS = 'userSearchConditions';
    /**
     * Called to load available reports
     */
    const LOAD_REPORTS = 'loadReports';
    /**
     * Called before view render, you can change variables from here
     */
    const BEFORE_RENDER = 'beforeRender';
    /**
     * Called after view render, you can change output from there
     * @see Am_Event_AfterRender 
     */
    const AFTER_RENDER = 'afterRender';    
    /** @deprecated, use INIT_ACCESS_TABLES instead */
    const INIT_CONTENT_PAGES = 'initContentPages';
    const INIT_ACCESS_TABLES = 'initAccessTables';
 
    const LOAD_ADMIN_DASHBOARD_WIDGETS = 'loadAdminDashboardWidgets';
 
    /**
     * Add sample data to database (@link AdminBuildController)
     * $user->save() will be called after hook finished
     * <li>{@link User} user</li>
     * <li>{@link string} $demoId</li>
     * <li>{@link int} $usersCreated</li>
     * <li>{@link int} $usersTotal</li>
     */
    const BUILD_DEMO = 'buildDemo';
    /**
     * Update database structure
     * <li>{@link dbsync} Am_DbSync desired database structure</li>
     */
    const DB_SYNC = 'dbSync';
    /**
     * Choose a signup form based on request parameters
     *
     * @param User $user
     * @param Am_Request $request
     * @link Am_Event::getReturn()
     * @link Am_Event::setReturn()
     */
    const LOAD_SIGNUP_FORM = 'loadSignupForm';
    /**
     * Choose a profile form based on user
     *
     * @param User $user
     * @link Am_Event::getReturn()
     * @link Am_Event::setReturn()
     */
    const LOAD_PROFILE_FORM = 'loadProfileForm';
    /**
     * Called when 2 user records are merged
     * 
     * @param User $target
     * @param User $source
     */
    const USER_MERGE = 'userMerge';
    /**
     * Called before 2 user records are going to be merged by admin
     * 
     * @param User $target
     * @param User $source
     */
    const USER_BEFORE_MERGE = 'userBeforeMerge';
 
    /**
     * Insert Additional items to admin Clear Old Records controller 
     * 
     * to utilize, you have to call $event->addReturn($arr, 'mykey'), arr must have
     * a format like this:
     * <code>
     * array(
     *           'method' => array($this->getDi()->adminLogTable, 'clearOld'),
     *           'title'  => 'Admin Log',
     *           'desc'   => 'admin log table (used by admin only)',
     *  )
     * </code>
     */
    const CLEAR_ITEMS = 'clearItems';
 
 
    /**
     *  Add ability to set custom placeholders to mail template.
     *  Am_Mail_Template $template is passed as a parameter;
     */
    const MAIL_TEMPLATE_BEFORE_PARSE = 'mailTemplateBeforeParse';
 
    /**
     *  Add ability to set custom placeholders to mail template.
     *  @param Am_SimpleTemplate $template
     *  @param string $body
     *  @param string $subject
     */
    const MAIL_SIMPLE_TEMPLATE_BEFORE_PARSE = 'mailSimpleTemplateBeforeParse';
 
    /**
     * @param stdClass $col
     * @param User $user
     * @param Invoice $invoice
     * @param InvoicePayment $payment
     */
    const PDF_INVOICE_COL_LEFT = 'pdfInvoiceColLeft';
    const PDF_INVOICE_COL_RIGHT = 'pdfInvoiceColRight';
 
    /**
     * @param Am_Pdf_Page_Decorator $page
     * @param stdClass $pointer use $pointer->value to retrieve current offset and update it
     * @param User $user
     * @param Invoice $invoice
     * @param InvoicePayment $payment
     */
    const PDF_INVOICE_BEFORE_TABLE = 'pdfInvoiceBeforeTable';
    const PDF_INVOICE_AFTER_TABLE = 'pdfInvoiceAfterTable';
 
    /**
     * Triggered when new invoice created on product upgrade
     * you may change invoice settings before it is passed
     * to paysystem plugin
     */
    const BEFORE_PRODUCT_UPGRADE = 'beforeProductUpgrade';
 
    /**
     * Called immediately before form rendering
     * may be user to change element styles
     * @param Am_Form $form
     */
    const FORM_BEFORE_RENDER = 'formBeforeRender';
 
    /**
     * Called during signup/renewal form display
     * may be used to modify products list in order form
     * @see Am_Event::getReturn() 
     * @see Am_Event::setReturn()
     */
    const SIGNUP_FORM_GET_PRODUCTS = 'signupFormGetProducts';
    /**
     * Called during signup/renewal form display
     * may be used to modify products list in order form
     * called AFTER products are filtered according to "require"/"disallow"
     * conditions
     * @see Am_Event::getReturn() 
     * @see Am_Event::setReturn()
     */
    const SIGNUP_FORM_GET_PRODUCTS_FILTERED = 'signupFormGetProductsFiltered';
 
    /**
     * Called during signup/renewal form display
     * may be used to modify paysystem list in order form
     * @see Am_Event::getReturn() 
     * @see Am_Event::setReturn()
     */
    const SIGNUP_FORM_GET_PAYSYSTEMS = 'signupFormGetPaysystems';
 
    /**
     * Triggered before signup data will be processed. (before invoice/user  will be created)
     * @param array $vars  - contains data collected from all signup forms.
     * May be usefull to make additional checks on data 
     * 
     */
    const SIGNUP_PAGE_BEFORE_PROCESS = 'signupPageBeforeProcess';
 
    /**
     * Triggered just before redirect to payment system
     * @param Invoice $invoice
     * @param mixed $controller
     */
    const INVOICE_BEFORE_PAYMENT = 'invoiceBeforePayment';
 
    /**
     * Triggered just before redirect to payment system (on signup/renew page)
     * @param Invoice $invoice
     * @param array $vars
     * @param Am_Form_Signup $form
     */
    const INVOICE_BEFORE_PAYMENT_SIGNUP = 'invoiceBeforePaymentSignup';
 
    /**
     * Triggered just after new invoice instance create (on signup/renew page)
     * may be used to attach some data from vars to invoice
     *
     * @param Invoice $invoice
     * @param array $vars
     * @param Am_Form_Signup $form
     */
    const INVOICE_SIGNUP = 'invoiceSignup';
 
    /**
     * Calculation of product (access) start date on first payment and renewals
     * @param bool isFirstPayment
     * @param Invoice $invoice
     * @param InvoiceItem $item
     * @link Am_Event::getReturn()
     * @link Am_Event::setReturn()
     */
    const CALCULATE_START_DATE = 'calculateStartDate';
 
    /**
     * Expand types constant to list of resource types
     *
     * @param enum(ResourceAccess::USER_VISIBLE_TYPES, ResourceAccess::USER_VISIBLE_PAGES) $type
     * @link Am_Event::getReturn()
     * @link Am_Event::setReturn()
     */
    const GET_RESOURCE_TYPES = 'getResourceTypes';
 
    /**
     * Ability to chage login regexp
     *
     * @param bool login_disallow_spaces
     * @link Am_Event::getReturn()
     * @link Am_Event::setReturn()
     */
    const GET_LOGIN_REGEX = 'getLoginRegex';
 
    /**
     * Ability to chage strong pass regexp
     *
     * @link Am_Event::getReturn()
     * @link Am_Event::setReturn()
     */
    const GET_STRONG_PASSWORD_REGEX = 'getStrongPasswordRegex';
    ....
}