Class Registry

Description

Class Registry is an singleton object factory and registry class.

Many objects (especially components) should only exist once in an application. The Registry provides an interface to register these objects and to get instances of them.

Use the factories whenever you want to load an application component like Service, Model, View or Filter. If it exists it will be returned from the registry, otherwise it will be created, registered and returned afterwards. There is also an abtract factory for Database objects. That factory relies on a Config object.

Internal application components should never be registered by the developer. These modules are created and registered by calling the corresponding static method.

Located in /registry.php (line 24)

PHOOL
   |
   --Registry
Variable Summary
static mixed $modules
static mixed $registry
Method Summary
static Database &Database ([string $driver = false], [string $db_name = false], [string $db_host = false], [string $db_user = false], [string $db_pass = false])
static Filter &Filter (string $name, Request 1, Forward 2)
static Object &Instance (scalar $index)
static Model &Model (string $name, [array $data = array( )])
static void register (scalar $index, Object &$obj)
static string registered (string $index, [string $module = false])
static Service &Service (string $name, Request &$request, Forward 2)
static View &View (string $name, Forward &$forward)
void &DAO ([ $daotype = false])
void __clone ()
Variables
static mixed $modules (line 34)

Static Registry Container for Singleton modules

  • access: private
static mixed $registry (line 29)

Dynamic Registry Container for own Singletons

  • access: private

Inherited Variables

Inherited from PHOOL

PHOOL::$debug
PHOOL::$errorlabels
PHOOL::$errorlevels
PHOOL::$errors
PHOOL::$exists
PHOOL::$logdir
PHOOL::$loglevel
PHOOL::$objname
Methods
static Database (line 170)

Database Factory

This factory uses a Config object to connect to a Database if present.

The following config values are searched on connect:

  • db_host: the database server to connect to
  • db_name: the database name to connect to
  • db_user: the database user to login with
  • db_passwd: the password to login with
You may also pass connection parameters directly to the factory if you need to connect to mulitple databases in one component.

static Database &Database ([string $driver = false], [string $db_name = false], [string $db_host = false], [string $db_user = false], [string $db_pass = false])
  • string $driver: name of database driver to return
  • string $db_name: name of database to connect to
  • string $db_host: name of database host to connect to
  • string $db_user: name of database user to connect with
  • string $db_pass: password of database user to connect with
static Filter (line 111)

Filter Factory

static Filter &Filter (string $name, Request 1, Forward 2)
  • Request 1: the request object to operate on
  • Forward 2: the forward object to operate on
  • string $name: name of Filter class to load
static Instance (line 77)

Return a Singleton instance from registry

static Object &Instance (scalar $index)
  • scalar $index: index of config object in registry
static Model (line 126)

Model Factory

static Model &Model (string $name, [array $data = array( )])
  • string $name: name of Model class to load
  • array $data: initial Model data
static register (line 42)

Register an Object instance as singleton.

static void register (scalar $index, Object &$obj)
  • scalar $index: index of object instance in registry
  • Object &$obj: the object instance to register
static registered (line 55)

Test if an Object instance is registred

  • return: type of registered object
static string registered (string $index, [string $module = false])
  • string $index: index where to search in registry
  • string $module: module type of module
static Service (line 95)

Service Factory

static Service &Service (string $name, Request &$request, Forward 2)
  • Forward 2: the forward object to operate on
  • string $name: name of Service class to load
  • Request &$request: the request object to operate on
static View (line 141)

View Factory

static View &View (string $name, Forward &$forward)
  • string $name: name of View class to load
  • Forward &$forward: the forward object to operate on
DAO (line 227)

DAO factory

void &DAO ([ $daotype = false])
  • $daotype
__clone (line 252)

Deny cloning of Registry

  • access: public
void __clone ()

Inherited Methods

Inherited From PHOOL

PHOOL::PHOOL()
PHOOL::debug()
PHOOL::error()
PHOOL::get_errors()
PHOOL::handle_error()
PHOOL::has_error()
PHOOL::log_error()
PHOOL::set_debug()
PHOOL::set_logdir()
PHOOL::set_loglevel()
Class Constants

Inherited Constants

Inherited from PHOOL

PHOOL::ERROR
PHOOL::UNKNOWN
PHOOL::USER
PHOOL::WARNING

Documentation generated on Tue, 12 May 2009 23:09:41 +0200 by phpDocumentor 1.4.1