SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/Helpers/DatabaseSync.php

  1. <?php
  2. /*
  3.  * Copyright (C) 2017 Karmabunny Pty Ltd.
  4.  *
  5.  * This file is a part of SproutCMS.
  6.  *
  7.  * SproutCMS is free software: you can redistribute it and/or modify it under the terms
  8.  * of the GNU General Public License as published by the Free Software Foundation, either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * For more information, visit <http://getsproutcms.com>.
  12.  */
  13.  
  14. // kate: tab-width 4; indent-width 4; space-indent on; word-wrap off; word-wrap-column 120;
  15. // :tabSize=4:indentSize=4:noTabs=true:wrap=false:maxLineLen=120:mode=php:
  16.  
  17. namespace Sprout\Helpers;
  18.  
  19. use karmabunny\pdb\Compat\DatabaseSync as RealDatabaseSync;
  20. use karmabunny\pdb\Pdb as RealPdb;
  21.  
  22. /**
  23. * Provides a system for syncing a database to a database definition.
  24. *
  25. * The database definition is stored in one or more XML files, which get merged
  26. * together before the sync is done.
  27. * Contains code that may be MySQL specific.
  28. **/
  29. class DatabaseSync extends RealDatabaseSync
  30. {
  31.  
  32. /** @inheritdoc */
  33. public static function getPdb(): RealPdb
  34. {
  35. return Pdb::getInstance();
  36. }
  37.  
  38.  
  39. /**
  40.   * Load the db_struct.xml from core and from all modules
  41.   */
  42. public function loadStandardXmlFiles()
  43. {
  44. $this->loadXml(APPPATH . 'db_struct.xml');
  45.  
  46. $module_paths = Register::getModuleDirs();
  47. foreach ($module_paths as $path) {
  48. $path .= '/db_struct.xml';
  49. if (file_exists($path)) {
  50. $this->loadXml($path);
  51. }
  52. }
  53. }
  54. }
  55.