2 namespace TYPO3\CMS\Extensionmanager\Utility\Importer
;
4 /***************************************************************
7 * (c) 2010 Marcus Krause <marcus#exp2010@t3sec.info>
8 * Steffen Kamper <info@sk-typo3.de>
11 * This script is part of the TYPO3 project. The TYPO3 project is
12 * free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * The GNU General Public License can be found at
18 * http://www.gnu.org/copyleft/gpl.html.
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * Module: Extension manager - Mirror list importer
30 * @author Marcus Krause <marcus#exp2010@t3sec.info>
31 * @author Steffen Kamper <info@sk-typo3.de>
34 * Importer object for mirror list.
36 * @author Marcus Krause <marcus#exp2010@t3sec.info>
37 * @author Steffen Kamper <info@sk-typo3.de>
39 * @package Extension Manager
40 * @subpackage Utility/Importer
42 class MirrorListUtility
implements SplObserver
{
45 * Keeps instance of a XML parser.
47 * @var \TYPO3\CMS\Extensionmanager\Utility\Parser\MirrorXmlAbstractParser
52 * Keeps mirrors' details.
56 protected $arrTmpMirrors = array();
61 * Method retrieves and initializes extension XML parser instance.
63 * @throws tx_em_XmlException
65 public function __construct() {
66 // TODO catch parser exception
67 $this->parser
= \TYPO3\CMS\Extensionmanager\Utility\Parser\XmlParserFactory
::getParserInstance('mirror');
68 if (is_object($this->parser
)) {
69 $this->parser
->attach($this);
71 throw new \TYPO3\CMS\Extensionmanager\Exception\
ExtensionManagerException(get_class($this) . ': No XML parser available.', 1342640390);
76 * Method collects mirrors' details and returns instance of
77 * Tx_Extensionmanager_Domain_Model_Mirrors with retrieved details.
79 * @param string $localMirrorListFile absolute path to local mirror xml.gz file
80 * @return \TYPO3\CMS\Extensionmanager\Domain\Model\Mirrors
82 public function getMirrors($localMirrorListFile) {
83 $zlibStream = 'compress.zlib://';
84 $this->parser
->parseXml($zlibStream . $localMirrorListFile);
85 /** @var $objRepositoryMirrors \TYPO3\CMS\Extensionmanager\Domain\Model\Mirrors */
86 $objRepositoryMirrors = \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Mirrors');
87 $objRepositoryMirrors->setMirrors($this->arrTmpMirrors
);
88 $this->arrTmpMirrors
= array();
89 return $objRepositoryMirrors;
93 * Method receives an update from a subject.
95 * @param SplSubject $subject a subject notifying this observer
98 public function update(\SplSubject
$subject) {
99 // TODO mirrorxml_abstract_parser
100 if (is_subclass_of($subject, 'TYPO3\\CMS\\Extensionmanager\\Utility\\Parser\\XmlAbstractParser')) {
101 $this->arrTmpMirrors
[] = $subject->getAll();