TYPO3 CMS  TYPO3_8-7
XmlParserFactory.php
Go to the documentation of this file.
1 <?php
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 
21 {
28  protected static $instance = [];
29 
38  protected static $parsers = [
39  'extension' => [
40  \TYPO3\CMS\Extensionmanager\Utility\Parser\ExtensionXmlPushParser::class => 'ExtensionXmlPushParser.php',
41  \TYPO3\CMS\Extensionmanager\Utility\Parser\ExtensionXmlPullParser::class => 'ExtensionXmlPullParser.php',
42  ],
43  'mirror' => [
44  \TYPO3\CMS\Extensionmanager\Utility\Parser\MirrorXmlPushParser::class => 'MirrorXmlPushParser.php',
45  \TYPO3\CMS\Extensionmanager\Utility\Parser\MirrorXmlPullParser::class=> 'MirrorXmlPullParser.php',
46  ]
47  ];
48 
59  public static function getParserInstance($parserType, $excludeClassNames = '')
60  {
61  if (!isset(self::$instance[$parserType]) || !is_object(self::$instance[$parserType]) || !empty($excludeClassNames)) {
62  // reset instance
63  self::$instance[$parserType] = ($objParser = null);
64  foreach (self::$parsers[$parserType] as $className => $file) {
65  if (!\TYPO3\CMS\Core\Utility\GeneralUtility::inList($excludeClassNames, $className)) {
67  if ($objParser->isAvailable()) {
68  self::$instance[$parserType] = &$objParser;
69  break;
70  }
71  $objParser = null;
72  }
73  }
74  }
75  return self::$instance[$parserType];
76  }
77 }
static makeInstance($className,... $constructorArguments)
static getParserInstance($parserType, $excludeClassNames='')