|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace embARCBundle\Lib\DownloadInfo; |
| 4 | + |
| 5 | +use AppBundle\Lib\DownloadInfo\AbstractDownloadInfo; |
| 6 | +use DeviceDetector\Parser\OperatingSystem as OSParser; |
| 7 | + |
| 8 | +class embARCDownloadInfo extends AbstractDownloadInfo |
| 9 | +{ |
| 10 | + protected $supportedOS = array( |
| 11 | + 'Windows' => array('name' => 'Windows', 'route' => 'embarc_download_windows', 'installer' => true), |
| 12 | + 'Mac' => array('name' => 'macOS', 'route' => 'embarc_download_mac', 'installer' => true), |
| 13 | + 'Linux' => array('name' => 'Linux', 'route' => 'embarc_download_linux', 'installer' => false), |
| 14 | + ); |
| 15 | + protected $userAgent; |
| 16 | + protected $downloadInfo; |
| 17 | + |
| 18 | + protected function detectOS() |
| 19 | + { |
| 20 | + $osParser = new OSParser(); |
| 21 | + $osParser->setUserAgent($this->userAgent); |
| 22 | + $detectedOS = $osParser->parse(); |
| 23 | + |
| 24 | + if ($detectedOS && array_key_exists($detectedOS['name'], $this->supportedOS)) { |
| 25 | + return $this->supportedOS[$detectedOS['name']]; |
| 26 | + } |
| 27 | + |
| 28 | + return array('name' => false, 'route' => 'embarc_download'); |
| 29 | + } |
| 30 | + |
| 31 | + public function parse() |
| 32 | + { |
| 33 | + $this->downloadInfo = $this->detectOS(); |
| 34 | + $this->downloadInfo['version'] = '1.4.20251129'; |
| 35 | + $this->downloadInfo['date'] = '2025-11-29'; |
| 36 | + $this->downloadInfo['versionPath'] = '20251129'; |
| 37 | + } |
| 38 | + |
| 39 | + public function getVersionPath() |
| 40 | + { |
| 41 | + return $this->downloadInfo['versionPath']; |
| 42 | + } |
| 43 | +} |
0 commit comments