source: subversion/branches/devel-vnext/program/include/rcube/registry.php @ 605

Last change on this file since 605 was 605, checked in by till, 6 years ago

+ return false if registry is not present

File size: 1.6 KB
Line 
1<?php
2/**
3 * rcRegistry
4 *
5 * @final
6 * @author Till Klampaeckel <till@php.net>
7 * @since  0.1-rc1
8 */
9class rcRegistry
10{
11    function rcRegistry()
12    {
13        return false;
14    }
15
16    function __construct()
17    {
18        return false;
19    }
20
21    function set($var, $val = '', $ns = null)
22    {
23        if (empty($var) === true) {
24            return false;
25        }
26        if (isset($GLOBALS['rcRegistry']) === false) {
27            $GLOBALS['rcRegistry'] = array();
28        }
29        if (is_null($ns) === true) {
30            $GLOBALS['rcRegistry'][$var] = $val;
31            return true;
32        }
33        if (isset($GLOBALS['rcRegistry'][$ns]) === false) {
34            $GLOBALS['rcRegistry'][$ns] = array();
35        }
36        $GLOBALS['rcRegistry'][$ns][$var] = $val;
37        return true;
38    }
39
40    function get($var, $ns = null)
41    {
42        if (empty($var) === true) {
43            return false;
44        }
45        if (is_null($ns) === true) {
46            if (isset($GLOBALS['rcRegistry'][$var]) === false) {
47                return false;
48            }
49            return $GLOBALS['rcRegistry'][$var];
50        }
51        if (isset($GLOBALS['rcRegistry'][$ns]) === false) {
52            return false;
53        }
54        if (isset($GLOBALS['rcRegistry'][$ns][$var]) === false) {
55            return false;
56        }
57        return $GLOBALS['rcRegistry'][$ns][$var];
58    }
59
60    function purge()
61    {
62        unset($GLOBALS['rcRegistry']);
63        return true;
64    }
65
66    function getAll()
67    {
68        if (isset($GLOBALS['rcRegistry']) === false) {
69            return false;
70        }
71        return $GLOBALS['rcRegistry'];
72    }
73}
74
75?>
Note: See TracBrowser for help on using the repository browser.