[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/toolkit/src/ -> lmbToolkit.class.php (summary)

(no description)

File Size: 308 lines (10 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

lmbToolkit:: (17 methods):
  setTools()
  setProperties()
  instance()
  _ensureInstance()
  setup()
  save()
  restore()
  extend()
  merge()
  set()
  get()
  setRaw()
  getRaw()
  __call()
  _ensureSignatures()
  _mapPropertyToGetMethod()
  _mapPropertyToSetMethod()


Class: lmbToolkit  - X-Ref

Toolkit is an implementation of Dinamic Service Locator pattern
The idea behind lmbToolkit class is simple:
1) lmbToolkit is a Singleton
2) lmbToolkit consists of so called tools. Tools is an object of any class that supports {@link lmbToolkitTools} interface
3) lmbToolkit redirects all non existing methods via magic __call to tools if these methods were named in $tools :: getToolsSignatures() result.
4) lmbToolkit also acts as a registry. You can put any data into toolkit and get them out at any place of your application
As a result we get an easily accessible object that we can extend with any methods we need.
We can also replace one tools with others thus we can return to client code completely different results from the same toolkit methods.
lmbToolkit also supports magic getters and setters. Say you have tools with getVar() method and you call $toolkit->get('var') then tools->getVar() will be actually called
Example of usage:
<code>
lmb_require('limb/net/src/lmbNetTools.class.php');
lmbToolkit :: merge(new lmbNetTools());
lmb_require('limb/net/src/toolkit/lmbDbTools.class.php');
lmbToolkit :: merge(new lmbDbTools());
// somethere in client code
$toolkit = lmbToolkit :: instance();
$toolkit->set('my_var', $value)'
$request = $toolkit->getRequest(); // supported by lmbNetTools
$same_request = $toolkit->get('requets'); // will delegate to getRequest()
$db_connection = $toolkit->getDefaultDbConnection(); // supported by lmbDbTools
$toolkit->get('my_var'); // returns $value value
</code>

setTools($tools)   X-Ref
Sets new tools object and clear signatures cache

param: lmbToolkitTools

setProperties($properties)   X-Ref
Sets new set of toolkit data

param: array

instance()   X-Ref
Follows Singleton pattern interface
Returns toolkit instance. Takes instance from {@link lmbRegistry)
If instance is not initialized yet - creates one with empty tools

return: lmbToolkit The only instance of lmbToolkit class

_ensureInstance()   X-Ref
Ensures that instance of lmbToolkit class is exists.
If instance is not initialized yet - creates one with empty tools

return: void

setup($tools)   X-Ref
Fills toolkit instance with suggested tools and registers this tools in {@ling lmbRegisty}

return: lmbToolkit The only instance of lmbToolkit class

save()   X-Ref
Save current tools object in registry stack and creates a new one using currently saved empty copy of tools object

return: lmbToolkit The only instance of lmbToolkit class

restore()   X-Ref
Restores previously saved tools object instance from {@link lmbRegistry} stack and sets this tools into toolkit instance

return: lmbToolkit The only instance of lmbToolkit class

extend($tools)   X-Ref
Extends current tools with new tools
Merges tools together using {@link lmbCompositeNonItersectingToolkitTools} that doesn't allow tools methods intersection

return: lmbToolkit The only instance of lmbToolkit class

merge($tools)   X-Ref
Extends current tools with new tools
Merges tools together using {@link lmbCompositeToolkitTools}

return: lmbToolkit The only instance of lmbToolkit class

set($var, $value)   X-Ref
Sets variable into toolkit
Checks if appropriate setter method in tools exists to delegate to

return: void

get($var)   X-Ref
Gets variable from toolkit
Checks if appropriate getter method in tools exists to delegate to

return: void

setRaw($var, $value)   X-Ref
Sets variable from toolkit
Doesn't check if appropriate setter method in tools exists to delegate to

return: void

getRaw($var)   X-Ref
Gets variable from toolkit
Doesn't check if appropriate getter method in tools exists to delegate to

return: void

__call($method, $args)   X-Ref
Magic caller. Delegates to {@link $tools} if $tools_signatures has required method

param: string Method name
param: array Method arguments
return: mixed

_ensureSignatures()   X-Ref
Caches tools signatures. Fills {@link $tools_signatures}.

return: void

_mapPropertyToGetMethod($property)   X-Ref
No description

_mapPropertyToSetMethod($property)   X-Ref
No description



Generated: Thu Aug 28 04:51:15 2008 Cross-referenced by PHPXref 0.7