/** * {@inheritdoc} */ public function detectVersion(VersionedLibraryInterface $library) { if (!isset($this->configuration['version'])) { throw new UnknownLibraryVersionException($library); } $library->setVersion($this->configuration['version']); }
/** * {@inheritdoc} */ public function detectVersion(VersionedLibraryInterface $library) { if (!$library instanceof LocalLibraryInterface) { throw new UnknownLibraryVersionException($library); } $filepath = $this->appRoot . '/' . $library->getLocalPath() . '/' . $this->configuration['file']; if (!file_exists($filepath)) { throw new UnknownLibraryVersionException($library); } $file = fopen($filepath, 'r'); $lines = $this->configuration['lines']; while ($lines && ($line = fgets($file, $this->configuration['columns']))) { if (preg_match($this->configuration['pattern'], $line, $version)) { fclose($file); $library->setVersion($version[1]); return; } $lines--; } fclose($file); }