TYPO3  7.6
ClassAliasMap.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\ClassAliasLoader;
3 
4 /*
5  * This file is part of the class alias loader package.
6  *
7  * (c) Helmut Hummel <info@helhum.io>
8  *
9  * For the full copyright and license information, please view the LICENSE
10  * file that was distributed with this source code.
11  */
12 
18 {
22  protected static $classAliasLoader;
23 
33  public static function getClassNameForAlias($classNameOrAlias) {
34  if (!static::$classAliasLoader) {
35  return $classNameOrAlias;
36  }
37  return static::$classAliasLoader->getClassNameForAlias($classNameOrAlias);
38  }
39 
45  public static function hasAliasMaps()
46  {
47  return is_object(static::$classAliasLoader);
48  }
49 
56  public static function addAliasMap(array $aliasMap)
57  {
58  if (!static::$classAliasLoader) {
59  throw new \RuntimeException('Cannot set an alias map as the alias loader is not registered!', 1439228111);
60  }
61 
62  static::$classAliasLoader->addAliasMap($aliasMap);
63  }
64 
69  {
70  if (static::$classAliasLoader) {
71  throw new \RuntimeException('Cannot set the alias loader, as it is already registered!', 1439228112);
72  }
73  static::$classAliasLoader = $classAliasLoader;
74  }
75 
76 }