= Jaws_Registry core subsystem = (X) Package: Jaws API File: Jaws/Registry.php and Jaws/Registry/Key.php Object: Jaws::$Registry

The Jaws registry is used to store various dynamic configuration options. It can be rightfully compared to the Windows registry as it is comprised of a series of keys with values. It is common practice to group the options of a particular module into subsections.

Internally, the Jaws registry uses the Doctrine nested sets feature. It is possible to create more than one root key for different usages but the default root key is called 'jaws'. The root key can have any number of subkeys and all subkeys can have any number of subkeys.

Loading

When the registry is loaded (unless it is loaded in MODE_STRIP), the Jaws root key is automatically loaded.

Access

To access a root key, the Jaws_Registry::getRootKey() method is used. All the subkeys can be accessed hierarchically, much like a Jaws_DataObject derivative:

echo Jaws::$Registry->getRootKey('jaws')->a->foo->bar->key;

Types

The keys can be of different types, much like PHP types. Here is the list of supported types:

  • Integer (Jaws_Registry::TYPE_INT)
  • String (Jaws_Registry:TYPE_STRING)
  • Boolean (Jaws_Registry::TYPE_BOOLEAN)
  • Array (Jaws_Registry::TYPE_ARRAY)
  • Subkey (Jaws_Registry::TYPE_FOLDER)

Create

To add a key to the registry, you need to use the following method:

Jaws::$Registry->create('a.foo.bar.key', Jaws_Registry::TYPE_INT);

Modify

After creating a key, we need to set a value to it. This is done using the following method:

Jaws::$Registry->set('a.foo.bar.key', 1223);

Value

The key is now accessible. We can now get its value using:

var_dump(Jaws::$Registry->get('a.foo.bar.key'));

Which should output the following:

int(1223)

Save

Although the key is created and has a value, it is only local. It needs to be saved to the database. This accomplished by the following method:

Jaws::$Registry->save();

Delete

If you don't need a key anymore, you can delete it using the following method:

Jaws::$Registry->delete('a.foo.bar.key');

< Click here to go back to Core Subsystems section