MCPcopy Create free account
hub / github.com/ddev/ddev / GetDrupalVersion

Function GetDrupalVersion

pkg/ddevapp/drupal.go:319–335  ·  view source on GitHub ↗

GetDrupalVersion finds the drupal8+ version so it can be used for setting requirements. It can only work if there is configured Drupal8+ code

(app *DdevApp)

Source from the content-addressed store, hash-verified

317// for setting requirements.
318// It can only work if there is configured Drupal8+ code
319func GetDrupalVersion(app *DdevApp) (string, error) {
320 // For drupal6/7 we use the apptype provided as version
321 switch app.Type {
322 case nodeps.AppTypeDrupal6:
323 return "6", nil
324 case nodeps.AppTypeDrupal7:
325 return "7", nil
326 }
327 // Otherwise figure out the version from existing code
328 f := filepath.Join(app.GetAbsDocroot(false), "core/lib/Drupal.php")
329 hasVersion, matches, err := fileutil.GrepStringInFile(f, `const VERSION = '([0-9]+)`)
330 v := ""
331 if hasVersion {
332 v = matches[1]
333 }
334 return v, err
335}
336
337// isDrupal6App returns true if the app is of type Drupal6
338func isDrupal6App(app *DdevApp) bool {

Callers 8

writeDrupalSettingsPHPFunction · 0.85
isDrupal8AppFunction · 0.85
isDrupal9AppFunction · 0.85
isDrupal10AppFunction · 0.85
isDrupal11AppFunction · 0.85
isDrupal12AppFunction · 0.85
isDrupalAppFunction · 0.85

Calls 2

GrepStringInFileFunction · 0.92
GetAbsDocrootMethod · 0.80

Tested by

no test coverage detected