app = $app; $this->versionProbes = [ new Probe31($this->app), new Probe35($this->app), new Probe38($this->app), ]; } public function getRequirements() { if ($this->requirements) { return $this->requirements; } $this->requirements = [ BinariesProbe::create($this->app), CacheServerProbe::create($this->app), DataboxStructureProbe::create($this->app), FilesystemProbe::create($this->app), LocalesProbe::create($this->app), PhpProbe::create($this->app), SearchEngineProbe::create($this->app), SubdefsPathsProbe::create($this->app), SystemProbe::create($this->app), ]; return $this->requirements; } public function registerVersionProbe(VersionProbeInterface $probe) { $this->versionProbes[] = $probe; } /** * Return true if got the latest configuration file. * * @return bool */ public function isInstalled() { return $this->app['configuration.store']->isSetup(); } /** * */ public function isUpToDate() { return $this->isInstalled() && !$this->isUpgradable(); } /** * */ public function isBlank() { return !$this->isInstalled() && !$this->isMigrable(); } /** * * @return boolean */ public function isUpgradable() { if (!$this->isInstalled()) { return false; } $upgradable = version::lt($this->app->getApplicationBox()->get_version(), $this->app['phraseanet.version']->getNumber()); if (!$upgradable) { foreach ($this->app->getDataboxes() as $databox) { if (version::lt($databox->get_version(), $this->app['phraseanet.version']->getNumber())) { $upgradable = true; break; } } } return $upgradable; } /** * Returns true if a major migration script can be executed * * @return bool */ public function isMigrable() { return (Boolean) $this->getMigrations(); } public function isConnectedToDBHost() { $connectionConfig = $this->app['conf']->get(['main', 'database']); /** @var Connection $connection */ $connection = $this->app['db.provider']($connectionConfig); try { $connection->connect(); return true; } catch (\Exception $e) { return false; } } /** * @return MigrationInterface[] */ public function getMigrations(InputInterface $input = null, OutputInterface $output = null) { $migrations = []; if ($this->isUpToDate()) { return $migrations; } foreach ($this->versionProbes as $probe) { if($output) { $output->writeln(sprintf("configurationTester : probing \"%s\"", get_class($probe))); } if ($probe->isMigrable()) { $migrations[] = $probe->getMigration(); } } return $migrations; } }