system = $platform; $this->l = $l; $this->missing = array(); $this->dependencies = array(); if (array_key_exists('dependencies', $app)) { $this->dependencies = $app['dependencies']; } } /** * @param array $app * @returns array of missing dependencies */ public function analyze() { $this->analysePhpVersion(); $this->analyseSupportedDatabases(); return $this->missing; } private function analysePhpVersion() { if (isset($this->dependencies['php']['@attributes']['min-version'])) { $minVersion = $this->dependencies['php']['@attributes']['min-version']; if (version_compare($this->system->getPhpVersion(), $minVersion, '<')) { $this->missing[] = (string)$this->l->t('PHP %s or higher is required.', $minVersion); } } if (isset($this->dependencies['php']['@attributes']['max-version'])) { $maxVersion = $this->dependencies['php']['@attributes']['max-version']; if (version_compare($this->system->getPhpVersion(), $maxVersion, '>')) { $this->missing[] = (string)$this->l->t('PHP with a version less then %s is required.', $maxVersion); } } } private function analyseSupportedDatabases() { if (!isset($this->dependencies['database'])) { return; } $supportedDatabases = $this->dependencies['database']; if (empty($supportedDatabases)) { return; } $supportedDatabases = array_map(function($db) { if (isset($db['@value'])) { return $db['@value']; } return $db; }, $supportedDatabases); $currentDatabase = $this->system->getDatabase(); if (!in_array($currentDatabase, $supportedDatabases)) { $this->missing[] = (string)$this->l->t('Following databases are supported: %s', join(', ', $supportedDatabases)); } } }