User Tools

Site Tools


products:stewload:backstory

How do I instantiate Thee?

Let me count the ways.

There are no autoLoaders, no namespaces, no PSR standards or traits.

Phpfox provides methods for loading most scripts as libraries, services, and components.

Other script are included or required via standard php.

Each library, service or component has a dot notation class Id.

EG “phpfox.image.helper” or “image.helper” refer to /include/library/phpfox/image/helper.class.php

Phpfox::getLibClass

Requires (includes) a library script but does not instantiate the object

Phpfox::&getObject

Instantiates an object.

Instances are maintained in an internal static list self::$_aObject, where the (hash) key to this list is

md5($sClass . serialize($aParams));

This means that Phpfox::getLib('cdn') is a different instance than Phpfox::getLib('cdn',array('MyParam'⇒$MyValue)

If parameters are present they are passed to the constructor.

If the class has a method called getInstance, we have a factory method, and each successive call to getLib will return a new instance.

Phpfox::&getLib

Requires (includes) a library script and instantiates the object

It does this by calling getLib to load a script and getObject to get the instance.

BUT. In between, it messes with the library names, prepending, removing a “phpfox” prefix and hard-coded special cases. More on this later.

new

Not the “normal” way for phpfox to obtain a class instance. No conventions we can see.

It is up to the author to ensure a class has been loaded before executing.

The bulk of these are used in third party libraries. For example:

$oGetId3 = new getID3;

$purifier = new HTMLPurifier($config);

module service callbacks

* Module service mass callback, hasCallback use the new keyword to instantiate “on the fly”.

Here the fox does not use it's own loaders. They have hard-coded access to the module folder.

So any custom overrides will have to take these into account.

Phpfox::getService

These are handed off to Phpfox_Module::getService

Locates a service in the file system, includes, and instantiates via Phpfox::getObject

There is a story here.

Consider loading the following services:

user.groupUser_Service_Group_Group/module/user/include/service/group/group.class.php
user.group.processUser_Service_Group_Process/module/user/include/service/group/process.class.php
user.group.settingUser_Service_Group_Setting_Process/module/user/include/service/group/setting/process.class.php
user.group.setting.processUser_Service_Group_Setting_Setting/module/user/include/service/group/setting/setting.class.php

This is the crux of the issue using autoLoaders. Phpfox has devised a system where it is impossible to map a dot-notation class identifier to a real class by name alone.

Payment gateways

We did not look into these.

products/stewload/backstory.txt · Last modified: 2014/06/30 11:33 by steward