createBackdropSettingsFile manages creation and modification of settings.php and settings.ddev.php. If a settings.php file already exists, it will be modified to ensure that it includes settings.ddev.php, which contains ddev-specific configuration.
(app *DdevApp)
| 57 | // If a settings.php file already exists, it will be modified to ensure that it includes |
| 58 | // settings.ddev.php, which contains ddev-specific configuration. |
| 59 | func createBackdropSettingsFile(app *DdevApp) (string, error) { |
| 60 | settings := NewBackdropSettings(app) |
| 61 | |
| 62 | if !fileutil.FileExists(app.SiteSettingsPath) { |
| 63 | output.UserOut.Printf("No %s file exists, creating one", settings.SiteSettings) |
| 64 | if err := writeDrupalSettingsPHP(app); err != nil { |
| 65 | return "", err |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | included, err := fileutil.FgrepStringInFile(app.SiteSettingsPath, settings.SiteSettingsDdev) |
| 70 | if err != nil { |
| 71 | return "", err |
| 72 | } |
| 73 | |
| 74 | if included { |
| 75 | output.UserOut.Printf("Existing %s includes %s", settings.SiteSettings, settings.SiteSettingsDdev) |
| 76 | } else { |
| 77 | output.UserOut.Printf("Existing %s file does not include %s, modifying to include ddev settings", settings.SiteSettings, settings.SiteSettingsDdev) |
| 78 | |
| 79 | if err = appendIncludeToDrupalSettingsFile(app); err != nil { |
| 80 | return "", fmt.Errorf("failed to include %s in %s: %v", settings.SiteSettingsDdev, settings.SiteSettings, err) |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | if err = writeBackdropSettingsDdevPHP(settings, app.SiteDdevSettingsFile, app); err != nil { |
| 85 | return "", fmt.Errorf("failed to write Drupal settings file %s: %v", app.SiteDdevSettingsFile, err) |
| 86 | } |
| 87 | |
| 88 | return app.SiteDdevSettingsFile, nil |
| 89 | } |
| 90 | |
| 91 | // writeBackdropSettingsDdevPHP dynamically produces a valid settings.ddev.php file |
| 92 | // by combining a configuration object with a data-driven template. |
nothing calls this directly
no test coverage detected