[TASK] Remove @author lines
[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 class RegistryService {
21
22 /**
23 * @var \TYPO3\CMS\Core\Registry
24 * @inject
25 */
26 protected $registry;
27
28 /**
29 * @var string
30 */
31 protected $namespaceIdentifier = 'TYPO3\\CMS\\Lang';
32
33 /**
34 * Set namespace
35 *
36 * @param string $namespace The namespace
37 * @return void
38 */
39 public function setNamespace($namespace) {
40 $this->namespaceIdentifier = $namespace;
41 }
42
43 /**
44 * Get namespace
45 *
46 * @return string The namespace
47 */
48 public function getNamespace() {
49 return $this->namespaceIdentifier;
50 }
51
52 /**
53 * Check for existing registry entry
54 *
55 * @param string $name Registry entry name
56 * @param string $namespace Optional namespace
57 * @return bool TRUE if exists
58 */
59 public function has($name, $namespace = NULL) {
60 $namespace = (is_string($namespace) ? $namespace : $this->namespaceIdentifier);
61 $value = $this->registry->get($namespace, $name, '__NOTFOUND__');
62 return ($value !== '__NOTFOUND__');
63 }
64
65 /**
66 * Get registry entry
67 *
68 * @param string $name Registry entry name
69 * @param string $namespace Optional namespace
70 * @return mixed Registry content
71 */
72 public function get($name, $namespace = NULL) {
73 $namespace = (is_string($namespace) ? $namespace : $this->namespaceIdentifier);
74 return $this->registry->get($namespace, $name);
75 }
76
77 /**
78 * Add / override registry entry
79 *
80 * @param string $name Registry entry name
81 * @param mixed $value The value
82 * @param string $namespace Optional namespace
83 * @return void
84 */
85 public function set($name, $value, $namespace = NULL) {
86 $namespace = (is_string($namespace) ? $namespace : $this->namespaceIdentifier);
87 $this->registry->set($namespace, $name, $value);
88 }
89
90 /**
91 * Remove registry entry
92 *
93 * @param string $name Registry entry name
94 * @param string $namespace Optional namespace
95 * @return void
96 */
97 public function remove($name, $namespace = NULL) {
98 $namespace = (is_string($namespace) ? $namespace : $this->namespaceIdentifier);
99 $this->registry->remove($namespace, $name);
100 }
101
102 }