TYPO3  7.6
GetTypo3OrgService.php
Go to the documentation of this file.
1 <?php
3 
4 /***************************************************************
5  * Copyright notice
6  *
7  * (c) 2014 Thomas Maroschik <tmaroschik@dfau.de>
8  * All rights reserved
9  *
10  * This script is part of the TYPO3 project. The TYPO3 project is
11  * free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * The GNU General Public License can be found at
17  * http://www.gnu.org/copyleft/gpl.html.
18  *
19  * This script is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * This copyright notice MUST APPEAR in all copies of the script!
25  ***************************************************************/
26 
33 
37  protected $file;
38 
42  protected $data = array();
43 
48  public function __construct(\Composer\IO\IOInterface $io, $jsonUrl = 'https://get.typo3.org/json') {
49  $this->file = new \Composer\Json\JsonFile($jsonUrl, new \Composer\Util\RemoteFilesystem($io));
50  }
51 
55  protected function initializeData() {
56  if (empty($this->data)) {
57  $this->data = $this->file->read();
58  }
59  }
60 
64  public function addDistToPackage(\Composer\Package\Package $package) {
65  $this->initializeData();
66  $versionDigits = explode('.', $package->getPrettyVersion());
67  if (count($versionDigits) === 3) {
68  $branchVersion = $versionDigits[0] . '.' . $versionDigits[1];
69  $patchlevelVersion = $versionDigits[0] . '.' . $versionDigits[1] . '.' . $versionDigits[2];
70  if (isset($this->data[$branchVersion]) && isset($this->data[$branchVersion]['releases'][$patchlevelVersion])) {
71  $releaseData = $this->data[$branchVersion]['releases'][$patchlevelVersion];
72  if (isset($releaseData['checksums']['tar']['sha1']) && isset($releaseData['url']['tar'])) {
73  $package->setDistType('tar');
74  $package->setDistReference($patchlevelVersion);
75  $package->setDistUrl($releaseData['url']['tar']);
76  $package->setDistSha1Checksum($releaseData['checksums']['tar']['sha1']);
77  }
78  }
79  }
80  }
81 
82 }