© 2015 X2Engine Inc.

Customization Framework

From X2Engine
Revision as of 19:49, 18 October 2012 by Drsimonz (talk | contribs) (Extending Controllers)
Jump to: navigation, search


Introduction

X2EngineCRM provides the means to manually customize classes and templates without modifying the source files. This can be performed by creating new files in custom. The need for this arises because the source files may be overwritten (and their customizations destroyed) during each software update, whereas if customizations are stored in other files, they remain in effect, and barring any incompatibilities between new versions and customizations in those files, they will still work as intended.

Overview

(in progress)

Extending Controllers

Overriding the entire file is practical when dealing with view files or smaller classes (such as models), but controllers can present a bigger problem. It's only a matter of time before something in a 2000-line controller file will change in base code. This means you would have to manually merge the changes, which is time-consuming. To remedy this, we allow substitution of an extended class for any controller in X2Engine.

Whenever a controller is loaded, X2Engine checks for the same filename with "My" at the beginning. For example, if you want to override a single action to ContactsController, you can create a file called MyContactsController in /custom/protected/modules/contacts/controllers

class MyContactsController extends ContactsController {
    function actionIndex() {
        echo 'Hello World!';
    }
}

This file will automatically be used instead of ContactsController and should still work if ContactsController is changed in an update. You may still need to manually merge changes if an update alters the same part of the controller that you changed, but it will be much easier to find.

Known Issues

(in progress)