[TASK] Fix old classnames in extensionmanager
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Classes / Utility / Importer / MirrorListUtility.php
1 <?php
2 namespace TYPO3\CMS\Extensionmanager\Utility\Importer;
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
17 /**
18 * Module: Extension manager - Mirror list importer
19 */
20 /**
21 * Importer object for mirror list.
22 * @since 2010-02-10
23 */
24 class MirrorListUtility implements \SplObserver
25 {
26 /**
27 * Keeps instance of a XML parser.
28 *
29 * @var \TYPO3\CMS\Extensionmanager\Utility\Parser\AbstractMirrorXmlParser
30 */
31 protected $parser;
32
33 /**
34 * Keeps mirrors' details.
35 *
36 * @var array
37 */
38 protected $arrTmpMirrors = array();
39
40 /**
41 * Class constructor.
42 *
43 * Method retrieves and initializes extension XML parser instance
44 * @throws \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException
45 */
46 public function __construct()
47 {
48 // @todo catch parser exception
49 $this->parser = \TYPO3\CMS\Extensionmanager\Utility\Parser\XmlParserFactory::getParserInstance('mirror');
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
57 /**
58 * Method collects mirrors' details and returns instance of
59 * \TYPO3\CMS\Extensionmanager\Domain\Model\Mirrors with retrieved details.
60 *
61 * @param string $localMirrorListFile absolute path to local mirror xml.gz file
62 * @return \TYPO3\CMS\Extensionmanager\Domain\Model\Mirrors
63 */
64 public function getMirrors($localMirrorListFile)
65 {
66 $zlibStream = 'compress.zlib://';
67 $this->parser->parseXml($zlibStream . $localMirrorListFile);
68 /** @var $objRepositoryMirrors \TYPO3\CMS\Extensionmanager\Domain\Model\Mirrors */
69 $objRepositoryMirrors = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extensionmanager\Domain\Model\Mirrors::class);
70 $objRepositoryMirrors->setMirrors($this->arrTmpMirrors);
71 $this->arrTmpMirrors = array();
72 return $objRepositoryMirrors;
73 }
74
75 /**
76 * Method receives an update from a subject.
77 *
78 * @param \SplSubject $subject a subject notifying this observer
79 * @return void
80 */
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 }