“Auto Load” Method and Singleton Pattern helps to manage resource in appRain

12 Oct

It’s really easy to load a class in appRain. We don’t need to include the class but it attach on demand. “On demand” means when we create first instance of the class then system automatically include the class in the system.

But!

There are some common conversion to construct the class. Here is some guide line

1) The class name must be given with the combination of it’s directory path. Let say we have a class in:

development/plugin/paypal/standard.php

Then class name must be

Development_Plugin_Paypal_Standard

2. Class name must be in lower case.

Here each underscore ( _ ) is used as a directory separator so we must use it carefully.Once we have create the class the installation is done. It will be attached in the system when we will create it’s first instance. We can create the class object like

$object = new Development_Plugin_Paypal_Standard()

But appRain recommend in different way..

For plug-in it will be : $obj = App::Plugin(‘Paypal_Standard’);
For helper it will be : $obj = App::Helper(‘Paypal_Standard’);

But in some case if we need to create class object directly then we can use like
$obj = App::__Obj(‘Development_Plugin_Paypal_Standard’);

Because, in this way the system manage the resource in Singleton Pattern so that, It hepls not to over load resource any more.

😀

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: