[TASK] Cleanup and update language module
[Packages/TYPO3.CMS.git] / typo3 / sysext / lang / Classes / Service / RegistryService.php
1 <?php
2 namespace TYPO3\CMS\Lang\Service;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * Registry service
19 *
20 * @author Kai Vogel <k.vogel@reply.de>
21 */
22 class RegistryService {
23
24 /**
25 * @var \TYPO3\CMS\Core\Registry
26 * @inject
27 */
28 protected $registry;
29
30 /**
31 * @var string
32 */
33 protected $namespaceIdentifier = 'TYPO3\\CMS\\Lang';
34
35 /**
36 * Set namespace
37 *
38 * @param string $namespace The namespace
39 * @return void
40 */
41 public function setNamespace($namespace) {
42 $this->namespaceIdentifier = $namespace;
43 }
44
45 /**
46 * Get namespace
47 *
48 * @return string The namespace
49 */
50 public function getNamespace() {
51 return $this->namespaceIdentifier;
52 }
53
54 /**
55 * Check for existing registry entry
56 *
57 * @param string $name Registry entry name
58 * @param string $namespace Optional namespace
59 * @return bool TRUE if exists
60 */
61 public function has($name, $namespace = NULL) {
62 $namespace = (is_string($namespace) ? $namespace : $this->namespaceIdentifier);
63 $value = $this->registry->get($namespace, $name, '__NOTFOUND__');
64 return ($value !== '__NOTFOUND__');
65 }
66
67 /**
68 * Get registry entry
69 *
70 * @param string $name Registry entry name
71 * @param string $namespace Optional namespace
72 * @return mixed Registry content
73 */
74 public function get($name, $namespace = NULL) {
75 $namespace = (is_string($namespace) ? $namespace : $this->namespaceIdentifier);
76 return $this->registry->get($namespace, $name);
77 }
78
79 /**
80 * Add / override registry entry
81 *
82 * @param string $name Registry entry name
83 * @param mixed $value The value
84 * @param string $namespace Optional namespace
85 * @return void
86 */
87 public function set($name, $value, $namespace = NULL) {
88 $namespace = (is_string($namespace) ? $namespace : $this->namespaceIdentifier);
89 $this->registry->set($namespace, $name, $value);
90 }
91
92 /**
93 * Remove registry entry
94 *
95 * @param string $name Registry entry name
96 * @param string $namespace Optional namespace
97 * @return void
98 */
99 public function remove($name, $namespace = NULL) {
100 $namespace = (is_string($namespace) ? $namespace : $this->namespaceIdentifier);
101 $this->registry->remove($namespace, $name);
102 }
103
104 }