PluginObserver.class.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * The PluginObserver class is used alongside PluginManager to implement
  5. * the Observer Design Pattern.
  6. *
  7. * @package PhpMyAdmin
  8. */
  9. if (! defined('PHPMYADMIN')) {
  10. exit;
  11. }
  12. /* Each PluginObserver instance contains a PluginManager instance */
  13. require_once 'PluginManager.class.php';
  14. /**
  15. * This class implements the SplObserver interface
  16. *
  17. * @package PhpMyAdmin
  18. * @link http://php.net/manual/en/class.splobserver.php
  19. */
  20. abstract class PluginObserver implements SplObserver
  21. {
  22. /**
  23. * PluginManager instance that contains a list with all the observer
  24. * plugins that attach to it
  25. *
  26. * @var PluginManager
  27. */
  28. private $_pluginManager;
  29. /**
  30. * Constructor
  31. *
  32. * @param PluginManager $pluginManager The Plugin Manager instance
  33. */
  34. public function __construct($pluginManager)
  35. {
  36. $this->_pluginManager = $pluginManager;
  37. }
  38. /**
  39. * This method is called when any PluginManager to which the observer
  40. * is attached calls PluginManager::notify()
  41. *
  42. * TODO Declare this function abstract, removing its body,
  43. * as soon as we drop support for PHP 5.3.x.
  44. * See bug #3625
  45. *
  46. * @param SplSubject $subject The PluginManager notifying the observer
  47. * of an update.
  48. *
  49. * @return void
  50. *
  51. * @throws Exception
  52. */
  53. public function update (SplSubject $subject)
  54. {
  55. throw new Exception(
  56. 'PluginObserver::update must be overridden in child classes.'
  57. );
  58. }
  59. /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
  60. /**
  61. * Gets the PluginManager instance that contains the list with all the
  62. * plugins that attached to it
  63. *
  64. * @return PluginManager
  65. */
  66. public function getPluginManager()
  67. {
  68. return $this->_pluginManager;
  69. }
  70. /**
  71. * Setter for $_pluginManager
  72. *
  73. * @param PluginManager $_pluginManager the private instance that it will
  74. * attach to
  75. *
  76. * @return void
  77. */
  78. public function setPluginManager($_pluginManager)
  79. {
  80. $this->_pluginManager = $_pluginManager;
  81. }
  82. }
  83. ?>