appendIncludeToDrupalSettingsFile modifies the settings.php file to include the settings.ddev.php file, which contains ddev-specific configuration.
(app *DdevApp)
| 634 | // appendIncludeToDrupalSettingsFile modifies the settings.php file to include the settings.ddev.php |
| 635 | // file, which contains ddev-specific configuration. |
| 636 | func 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. |
| 663 | func drupalImportFilesAction(app *DdevApp, uploadDir, importPath, extPath string) error { |
no test coverage detected