MCPcopy Index your code
hub / github.com/ddev/ddev / appendIncludeToDrupalSettingsFile

Function appendIncludeToDrupalSettingsFile

pkg/ddevapp/drupal.go:636–660  ·  view source on GitHub ↗

appendIncludeToDrupalSettingsFile modifies the settings.php file to include the settings.ddev.php file, which contains ddev-specific configuration.

(app *DdevApp)

Source from the content-addressed store, hash-verified

634// appendIncludeToDrupalSettingsFile modifies the settings.php file to include the settings.ddev.php
635// file, which contains ddev-specific configuration.
636func appendIncludeToDrupalSettingsFile(app *DdevApp) error {
637 // Check if file is empty
638 contents, err := os.ReadFile(app.SiteSettingsPath)
639 if err != nil {
640 return err
641 }
642
643 // If the file is empty, write the complete settings file and return
644 if len(contents) == 0 {
645 return writeDrupalSettingsPHP(app)
646 }
647
648 // The file is not empty, open it for appending
649 file, err := os.OpenFile(app.SiteSettingsPath, os.O_RDWR|os.O_APPEND, 0644)
650 if err != nil {
651 return err
652 }
653 defer util.CheckClose(file)
654
655 _, err = file.Write([]byte(settingsIncludeStanza))
656 if err != nil {
657 return err
658 }
659 return nil
660}
661
662// drupalImportFilesAction defines the Drupal workflow for importing project files.
663func drupalImportFilesAction(app *DdevApp, uploadDir, importPath, extPath string) error {

Callers 2

manageDrupalSettingsFileFunction · 0.85

Calls 3

CheckCloseFunction · 0.92
writeDrupalSettingsPHPFunction · 0.85
WriteMethod · 0.65

Tested by

no test coverage detected