TYPO3 CMS  TYPO3_7-6
MirrorListUtility.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 
24 class MirrorListUtility implements \SplObserver
25 {
31  protected $parser;
32 
38  protected $arrTmpMirrors = [];
39 
46  public function __construct()
47  {
48  // @todo catch parser exception
50  if (is_object($this->parser)) {
51  $this->parser->attach($this);
52  } else {
53  throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException(get_class($this) . ': No XML parser available.', 1342640390);
54  }
55  }
56 
64  public function getMirrors($localMirrorListFile)
65  {
66  $zlibStream = 'compress.zlib://';
67  $this->parser->parseXml($zlibStream . $localMirrorListFile);
69  $objRepositoryMirrors = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extensionmanager\Domain\Model\Mirrors::class);
70  $objRepositoryMirrors->setMirrors($this->arrTmpMirrors);
71  $this->arrTmpMirrors = [];
72  return $objRepositoryMirrors;
73  }
74 
81  public function update(\SplSubject $subject)
82  {
83  // @todo mirrorxml_abstract_parser
84  if (is_subclass_of($subject, \TYPO3\CMS\Extensionmanager\Utility\Parser\AbstractXmlParser::class)) {
85  $this->arrTmpMirrors[] = $subject->getAll();
86  }
87  }
88 }
static getParserInstance($parserType, $excludeClassNames='')