‪TYPO3CMS  10.4
Mirrors.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
19 
25 {
31  protected ‪$mirrors = [];
32 
40  protected ‪$currentMirror;
41 
48  protected ‪$isRandomSelection = true;
49 
55  public function ‪setSelect($mirrorId = null)
56  {
57  if ($mirrorId === null) {
58  $this->isRandomSelection = true;
59  } else {
60  if (is_int($mirrorId) && $mirrorId >= 1 && $mirrorId <= count($this->mirrors)) {
61  $this->currentMirror = $mirrorId - 1;
62  }
63  }
64  }
65 
74  public function ‪getMirror()
75  {
76  $sumMirrors = count($this->mirrors);
77  if ($sumMirrors > 0) {
78  if (!is_int($this->currentMirror)) {
79  $this->currentMirror = random_int(0, $sumMirrors - 1);
80  }
81  return $this->mirrors[‪$this->currentMirror];
82  }
83  return null;
84  }
85 
91  public function ‪getMirrorUrl()
92  {
93  $mirror = $this->‪getMirror();
94  $mirrorUrl = $mirror['host'] . $mirror['path'];
95  return 'https://' . $mirrorUrl;
96  }
97 
104  public function ‪getMirrors()
105  {
106  return ‪$this->mirrors;
107  }
108 
115  public function ‪setMirrors(array ‪$mirrors)
116  {
117  if (count(‪$mirrors) >= 1) {
118  $this->mirrors = ‪$mirrors;
119  }
120  }
121 }
‪TYPO3\CMS\Extensionmanager\Domain\Model\Mirrors\$currentMirror
‪int $currentMirror
Definition: Mirrors.php:38
‪TYPO3\CMS\Extensionmanager\Domain\Model\Mirrors\getMirrors
‪array getMirrors()
Definition: Mirrors.php:101
‪TYPO3\CMS\Extbase\DomainObject\AbstractEntity
Definition: AbstractEntity.php:23
‪TYPO3\CMS\Extensionmanager\Domain\Model\Mirrors\setSelect
‪setSelect($mirrorId=null)
Definition: Mirrors.php:52
‪TYPO3\CMS\Extensionmanager\Domain\Model\Mirrors
Definition: Mirrors.php:25
‪TYPO3\CMS\Extensionmanager\Domain\Model\Mirrors\getMirrorUrl
‪string getMirrorUrl()
Definition: Mirrors.php:88
‪TYPO3\CMS\Extensionmanager\Domain\Model\Mirrors\$mirrors
‪array $mirrors
Definition: Mirrors.php:30
‪TYPO3\CMS\Extensionmanager\Domain\Model\Mirrors\setMirrors
‪setMirrors(array $mirrors)
Definition: Mirrors.php:112
‪TYPO3\CMS\Extensionmanager\Domain\Model
Definition: Dependency.php:16
‪TYPO3\CMS\Extensionmanager\Domain\Model\Mirrors\$isRandomSelection
‪bool $isRandomSelection
Definition: Mirrors.php:45
‪TYPO3\CMS\Extensionmanager\Domain\Model\Mirrors\getMirror
‪array getMirror()
Definition: Mirrors.php:71