[TASK] Re-work/simplify copyright header in PHP files - Part 9
[Packages/TYPO3.CMS.git] / typo3 / sysext / rsaauth / Classes / Storage / StorageFactory.php
1 <?php
2 namespace TYPO3\CMS\Rsaauth\Storage;
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 * This class contains a factory for the RSA backends.
18 *
19 * @author Dmitry Dulepov <dmitry@typo3.org>
20 */
21 class StorageFactory {
22
23 /**
24 * A list of all available storages. Currently this list cannot be extended.
25 * This is for security reasons to avoid inserting some dummy storage to
26 * the list.
27 *
28 * @var string
29 */
30 static protected $preferredStorage = 'TYPO3\\CMS\\Rsaauth\\Storage\\SplitStorage';
31
32 /**
33 * An instance of the storage. This member is set in the getStorage() function.
34 * It will not be an abstract storage as shown below but a real class, which is
35 * derived from the \TYPO3\CMS\Rsaauth\Storage\AbstractStorage.
36 *
37 * <!-- Please, keep the variable type! It helps IDEs to provide autocomplete! -->
38 *
39 * @var \TYPO3\CMS\Rsaauth\Storage\AbstractStorage
40 */
41 static protected $storageInstance = NULL;
42
43 /**
44 * Obtains a storage. This function will return a non-abstract class, which
45 * is derived from \TYPO3\CMS\Rsaauth\Storage\AbstractStorage. Applications should
46 * not use any methods that are not declared in the \TYPO3\CMS\Rsaauth\Storage\AbstractStorage.
47 *
48 * @return \TYPO3\CMS\Rsaauth\Storage\AbstractStorage A storage
49 */
50 static public function getStorage() {
51 if (is_null(self::$storageInstance)) {
52 self::$storageInstance = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj(self::$preferredStorage);
53 }
54 return self::$storageInstance;
55 }
56
57 /**
58 * Sets the preferred storage to the factory. This method can be called from
59 * another extension or ext_localconf.php
60 *
61 * @param string $preferredStorage Preferred storage
62 * @return void
63 */
64 static public function setPreferredStorage($preferredStorage) {
65 self::$preferredStorage = $preferredStorage;
66 }
67
68 }