TYPO3 CMS  TYPO3_7-6
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 
22 {
29  protected static $instance = [];
30 
39  protected static $parsers = [
40  'extension' => [
41  \TYPO3\CMS\Extensionmanager\Utility\Parser\ExtensionXmlPushParser::class => 'ExtensionXmlPushParser.php',
42  \TYPO3\CMS\Extensionmanager\Utility\Parser\ExtensionXmlPullParser::class => 'ExtensionXmlPullParser.php',
43  ],
44  'mirror' => [
45  \TYPO3\CMS\Extensionmanager\Utility\Parser\MirrorXmlPushParser::class => 'MirrorXmlPushParser.php',
46  \TYPO3\CMS\Extensionmanager\Utility\Parser\MirrorXmlPullParser::class=> 'MirrorXmlPullParser.php',
47  ]
48  ];
49 
60  public static function getParserInstance($parserType, $excludeClassNames = '')
61  {
62  if (!isset(self::$instance[$parserType]) || !is_object(self::$instance[$parserType]) || !empty($excludeClassNames)) {
63  // reset instance
64  self::$instance[$parserType] = ($objParser = null);
65  foreach (self::$parsers[$parserType] as $className => $file) {
66  if (!\TYPO3\CMS\Core\Utility\GeneralUtility::inList($excludeClassNames, $className)) {
68  if ($objParser->isAvailable()) {
69  self::$instance[$parserType] = &$objParser;
70  break;
71  }
72  $objParser = null;
73  }
74  }
75  }
76  return self::$instance[$parserType];
77  }
78 }
static getParserInstance($parserType, $excludeClassNames='')