TYPO3 CMS  TYPO3_8-7
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 
20 class MirrorListUtility implements \SplObserver
21 {
27  protected $parser;
28 
34  protected $arrTmpMirrors = [];
35 
42  public function __construct()
43  {
44  // @todo catch parser exception
46  if (is_object($this->parser)) {
47  $this->parser->attach($this);
48  } else {
49  throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException(
50  get_class($this) . ': No XML parser available.',
51  1476108687
52  );
53  }
54  }
55 
63  public function getMirrors($localMirrorListFile)
64  {
65  $zlibStream = 'compress.zlib://';
66  $this->parser->parseXml($zlibStream . $localMirrorListFile);
68  $objRepositoryMirrors = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extensionmanager\Domain\Model\Mirrors::class);
69  $objRepositoryMirrors->setMirrors($this->arrTmpMirrors);
70  $this->arrTmpMirrors = [];
71  return $objRepositoryMirrors;
72  }
73 
79  public function update(\SplSubject $subject)
80  {
81  // @todo mirrorxml_abstract_parser
82  if (is_subclass_of($subject, \TYPO3\CMS\Extensionmanager\Utility\Parser\AbstractXmlParser::class)) {
83  $this->arrTmpMirrors[] = $subject->getAll();
84  }
85  }
86 }
static makeInstance($className,... $constructorArguments)
static getParserInstance($parserType, $excludeClassNames='')