SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/Helpers/Replication.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. namespace Sprout\Helpers;
  15.  
  16. use Exception;
  17.  
  18.  
  19. /**
  20. * Functions for database replication.
  21. * I guess it could be used for cluster situations too.
  22. *
  23. * This default class has replication disabled.
  24. * To enable, replace this class with your own.
  25. **/
  26. class Replication
  27. {
  28.  
  29. public static function enabled()
  30. {
  31. return false;
  32. }
  33.  
  34.  
  35. /**
  36.   * Return the IP address or hostname of the write server to use
  37.   **/
  38. public static function getWriteHost()
  39. {
  40. throw new Exception('Replication not enabled');
  41. }
  42.  
  43.  
  44. /**
  45.   * Return the IP address or hostname of the read server to use
  46.   **/
  47. public static function getReadHost()
  48. {
  49. throw new Exception('Replication not enabled');
  50. }
  51.  
  52.  
  53. /**
  54.   * Checks we are using the correct server for admin.
  55.   *
  56.   * Return false if the server is correct
  57.   * Return the URL to redirect to if the server is incorrect.
  58.   **/
  59. public static function adminUrl()
  60. {
  61. return false;
  62. }
  63.  
  64.  
  65. /**
  66.   * Handle replication of a file to other servers.
  67.   * This is always called, even if replication is not enabled above.
  68.   *
  69.   * @param string The file which has just been added or updated.
  70.   * @return bool TRUE on success, FALSE on failure.
  71.   **/
  72. public static function postFileUpdate($filename)
  73. {
  74. return true;
  75. }
  76.  
  77. }
  78.