6.0.0-git
2019-11-19

Diff for Doc/Dev/RegistryH3 between 9 and 10

+ The Registry

**##red|This information is valid for Horde 3 only. See ((Doc/Dev/Registry)) for Horde 4 and later.##**

Horde's Registry is the glue that holds different applications together.

* The Registry system keeps track of Horde's application stack, and which app is currently running.
* When you switch applications, the registry will take care of correctly switching the gettext textdomain, loading the application configuration, and loading the user's application preferences.
* It also lets you determine configuration information about installed applications.
* The Registry lets you generate links to other apps.
 * Links will be to the application that provides the functionality.
 * Any arguments that the target script needs (headers for an email, for instance) will be filled out of the second argument to link().
* The Registry also lets you invoke methods in other applications
 * The registry.php config file defines where to find the code necessary to execute the method, and what application implements it.
 * Any application can be integrated this way; all you need to do is map it to the registry interface.

Things the Registry does when being instantiated:

# Importing the global configuration
# Setting up the session handler and starting the session
# Setting the language and gettext domain
# Restoring the registry information from cache or loading and parsing the registry configuration from {{config/registry.php}}
# Instantiating the global ((Doc/Dev/PermsPackage|Permission)) object
# Attaching a javascript notification listener

((Doc/Dev/FrameworkPackage|Click here)) for Registry usage examples. ((Doc/Dev/LegacyApps|Click here)) for examples how to use the Registry from outside of Horde.

++ registry.php

Here's an application's registry.php entry:

<code type="php">
$this->applications['whups'] = array(
    'fileroot' => dirname(__FILE__) . '/../whups',
    'webroot' => $this->applications['horde']['webroot'] . '/whups',
    'name' => _("Tickets"),
    'status' => 'active',
    'provides' => 'tickets',
    'menu_parent' => 'devel',
);
</code>

+++ fileroot

<code type="php">
    'fileroot' => dirname(__FILE__) . '/../whups',
</code>

The {{fileroot}} setting tells Horde where the application - in this case Whups - lives on the filesystem. The {{__FILE__}} constant is the current file; {{dirname()}} strips off the filename and turns it into just a directory.
This means that the location is by default relative to {{registry.php}} - under the {{horde/}} directory - which is almost always right. But it's configurable just in case.

+++ webroot

<code type="php">
    'webroot' => $this->applications['horde']['webroot'] . '/whups',
</code>

The {{webroot}} setting tells Horde where the application lives relative to the webserver's document root. Usually this is predictable as well, but you might want to give an application its own domain - for example, {{http://cvs.php.net/}}, which is powered by Horde and Chora.

+++ name

<code type="php">
    'name' => _("Tickets"),
</code>

The {{name}} setting surprisingly sets the human-readable name of the application. The {{_()}} is an alias for {{gettext()}}, which translates the name into other languages.

+++ status

<code type="php">
    'status' => 'active',
</code>

The {{status}} setting tells Horde what kind of application this is. Possible statuses are:

* inactive
* hidden
* notoolbar
* heading
* block
* admin
* active

+++ provides

<code type="php">
    'provides' => 'tickets',
</code>

The {{provides}} setting tells Horde if the application provides any APIs. In this case Whups provides the tickets API, which allows for adding and listing tickets. In turn, Horde knows that if it gets a request for a {{tickets/search}} method, it should pass it along to Whups.

+++ menu_parent

<code type="php">
    'menu_parent' => 'devel',
</code>

The {{menu_parent}} setting is just for the sidebar - it tells Horde what item to make the application of a child of. This lets you customize the menu to your heart's content. This can be left out or set to null for top-level items.