HomeBack home

S4
List of registered services

$Date$

 Table of contents

  Introduction

This example allows to retrieve a phparray view of registered services for an application.

[Top]

  Synopsis

$registry = &Registry::singleton();
$app = 'sw4p';
$registry->registerApplication($app]);
$registry->registerService($app, 'textdomain/set', 'functions.php', 'initTextDomain', 
                           array('language','domain','translationsDir')
                           );
...
$srv = $registry->getServices($app);

[Top]

  Parameters

string    $app          The desired application

[Top]

  Output

array(1) {
  ["textdomain"]=>
  array(1) {
    ["set"]=>
    array(3) {
      ["file"]=>
      string(13) "functions.php"
      ["function"]=>
      string(14) "initTextDomain"
      ["args"]=>
      array(3) {
        [0]=>
        string(8) "language"
        [1]=>
        string(6) "domain"
        [2]=>
        string(15) "translationsDir"
      }
    }
  }
}

[Top]

  Play example


<?php
/**
 * Example S4 for Config_Registry : registered Services
 * 
 * @version    0.1
 * @author     Laurent Laville <pear@laurent-laville.org>
 * @access     public
 * @package    Config_Registry
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
 *
 * $Id$
 */
 
require_once 'Config/Registry.php';
require_once '../handleError.php';

print "<h1>List of registered Services </h1>";

$registry =& Config_Registry::singleton();
$app = 'gettext';

print "<h2>try 1</h2>";

$reg = $registry->registerApplication($app, 'php-gettext plugin', realpath('.'));
handleError($reg);

$args = array('language','domain','translationsDir');
$srv = $registry->registerService($app, 'textdomain/set', 'functions.php', 'initTextDomain', $args);
handleError($srv);

$args = array('stringID');
$srv = $registry->registerService($app, 'message/get', 'functions.php', 'getMessage', $args);
handleError($srv);

$srv = $registry->getServices($app);
handleError($srv);

print "<pre>";
var_dump($srv);
print "</pre>";
?>

href:  examples/services/list.php
Run this script

[Top]