2
0

ApplicationConfigWriter.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. class Zend_Tool_Project_Utility_ApplicationConfigWriter
  3. {
  4. public function setFilename()
  5. {
  6. }
  7. protected function _writeArrayToConfig($configArray)
  8. {
  9. }
  10. protected function _writeStringToConfig()
  11. {
  12. $configKeyNames = array('resources', 'db');
  13. $newDbLines = array();
  14. $originalLines = file($this->_appConfigFilePath);
  15. $newLines = array();
  16. $insideSection = false;
  17. foreach ($originalLines as $originalLineIndex => $originalLine) {
  18. if ($insideSection === false && preg_match('#^\[' . $this->_sectionName . '#', $originalLine)) {
  19. $insideSection = true;
  20. }
  21. if ($insideSection) {
  22. if ((trim($originalLine) == null) || ($originalLines[$originalLineIndex + 1][0] == '[')) {
  23. foreach ($newDbLines as $newDbLine) {
  24. $newLines[] = $newDbLine;
  25. }
  26. $insideSection = null;
  27. }
  28. }
  29. $newLines[] = $originalLine;
  30. }
  31. $newConfigContents = implode('', $newLines);
  32. if (!$isPretend) {
  33. file_put_contents($this->_appConfigFilePath, $newConfigContents);
  34. }
  35. return $newConfigContents;
  36. }
  37. }