Subversion Repositories Applications.papyrus

Rev

Rev 2014 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2014 Rev 2150
Line 1... Line 1...
1
<?php
1
<?php
2
 
2
 
3
class Registre {
3
class Registre {
4
 
4
 
5
	private $aso_stock = array();
5
	private $aso_stock = array();
6
	private static $registre;
6
	private static $registre;
7
 
7
 
8
	public function __construct()
8
	public function __construct()
9
	{
9
	{
10
		
10
		
11
	}
11
	}
12
 
12
 
13
	public static function getInstance()
13
	public static function getInstance()
14
	{
14
	{
15
		if (self::$registre instanceof Registre) {
15
		if (self::$registre instanceof Registre) {
16
			return self::$registre;
16
			return self::$registre;
17
		}
17
		}
18
		self::$registre = new Registre;
18
		self::$registre = new Registre;
19
	    return self::$registre;
19
	    return self::$registre;
20
	}
20
	}
21
	
21
	
22
	function set($intitule, $objet)
22
	function set($intitule, $objet)
23
	{
23
	{
24
		if (is_array($objet) && isset($this->aso_stock[$intitule])) {
24
		if (is_array($objet) && isset($this->aso_stock[$intitule])) {
25
			$this->aso_stock[$intitule] = array_merge((array)$this->aso_stock[$intitule], (array)$objet);
25
			$this->aso_stock[$intitule] = array_merge((array)$this->aso_stock[$intitule], (array)$objet);
26
			$message = "Le tableau $intitule présent dans le registre a été fusionné avec un nouveau tableau de même intitulé !";
26
			$message = "Le tableau $intitule présent dans le registre a été fusionné avec un nouveau tableau de même intitulé !";
27
			trigger_error($message, E_USER_WARNING);
27
			trigger_error($message, E_USER_WARNING);
28
		} else {
28
		} else {
29
			$this->aso_stock[$intitule] = $objet;
29
			$this->aso_stock[$intitule] = $objet;
30
		}
30
		}
31
	}
31
	}
32
 
32
 
33
	function get($intitule)
33
	function get($intitule)
34
	{
34
	{
35
		if (isset($this->aso_stock[$intitule])) {
35
		if (isset($this->aso_stock[$intitule])) {
36
			return $this->aso_stock[$intitule];
36
			return $this->aso_stock[$intitule];
37
		}
37
		}
38
		return null;
38
		return null;
39
	}
39
	}
40
	
40
	
41
	function detruire($intitule)
41
	function detruire($intitule)
42
	{
42
	{
43
		if (isset($this->aso_stock[$intitule])) {
43
		if (isset($this->aso_stock[$intitule])) {
44
			unset($this->aso_stock[$intitule]);
44
			unset($this->aso_stock[$intitule]);
45
		}
45
		}
46
	}
46
	}
47
		
47
		
48
	public function etrePresent($intitule)
48
	public function etrePresent($intitule)
49
	{
49
	{
50
		if(isset($this->aso_stock[$intitule])){
50
		if(isset($this->aso_stock[$intitule])){
51
			return true;
51
			return true;
52
		}
52
		}
53
		return false;
53
		return false;
54
	}
54
	}
55
}
55
}
56
?>
56
?>
57
57