PicoPluginInterface.php.txt 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. /**
  3. * Common interface for Pico plugins
  4. *
  5. * For a list of supported events see {@link DummyPlugin}; you can use
  6. * {@link DummyPlugin} as template for new plugins. For a list of deprecated
  7. * events see {@link PicoDeprecated}.
  8. *
  9. * You SHOULD NOT use deprecated events when implementing this interface.
  10. * Deprecated events are triggered by the {@link PicoDeprecated} plugin, if
  11. * plugins which don't implement this interface are loaded. You can take
  12. * advantage from this behaviour if you want to do something only when old
  13. * plugins are loaded. Consequently the old events are never triggered when
  14. * your plugin is implementing this interface and no old plugins are present.
  15. *
  16. * If you're developing a new plugin, you MUST implement this interface. If
  17. * you're the developer of an old plugin, it is STRONGLY RECOMMENDED to use
  18. * the events introduced in Pico 1.0 when releasing a new version of your
  19. * plugin. If you want to use any of the new events, you MUST implement
  20. * this interface and update all other events you use.
  21. *
  22. * @author Daniel Rudolf
  23. * @link http://picocms.org
  24. * @license http://opensource.org/licenses/MIT
  25. * @version 1.0
  26. */
  27. interface PicoPluginInterface
  28. {
  29. /**
  30. * Constructs a new instance of a Pico plugin
  31. *
  32. * @param Pico $pico current instance of Pico
  33. */
  34. public function __construct(Pico $pico);
  35. /**
  36. * Handles a event that was triggered by Pico
  37. *
  38. * @param string $eventName name of the triggered event
  39. * @param array $params passed parameters
  40. * @return void
  41. */
  42. public function handleEvent($eventName, array $params);
  43. /**
  44. * Enables or disables this plugin
  45. *
  46. * @see PicoPluginInterface::isEnabled()
  47. * @see PicoPluginInterface::isStatusChanged()
  48. * @param boolean $enabled enable (true) or disable (false) this plugin
  49. * @param boolean $recursive when true, enable or disable recursively
  50. * In other words, if you enable a plugin, all required plugins are
  51. * enabled, too. When disabling a plugin, all depending plugins are
  52. * disabled likewise. Recursive operations are only performed as long
  53. * as a plugin wasn't enabled/disabled manually. This parameter is
  54. * optional and defaults to true.
  55. * @param boolean $auto enable or disable to fulfill a dependency
  56. * This parameter is optional and defaults to false.
  57. * @return void
  58. * @throws RuntimeException thrown when a dependency fails
  59. */
  60. public function setEnabled($enabled, $recursive = true, $auto = false);
  61. /**
  62. * Returns true if this plugin is enabled, false otherwise
  63. *
  64. * @see PicoPluginInterface::setEnabled()
  65. * @return boolean plugin is enabled (true) or disabled (false)
  66. */
  67. public function isEnabled();
  68. /**
  69. * Returns true if the plugin was ever enabled/disabled manually
  70. *
  71. * @see PicoPluginInterface::setEnabled()
  72. * @return boolean plugin is in its default state (true), false otherwise
  73. */
  74. public function isStatusChanged();
  75. /**
  76. * Returns a list of names of plugins required by this plugin
  77. *
  78. * @return string[] required plugins
  79. */
  80. public function getDependencies();
  81. /**
  82. * Returns a list of plugins which depend on this plugin
  83. *
  84. * @return object[] dependant plugins
  85. */
  86. public function getDependants();
  87. /**
  88. * Returns the plugins instance of Pico
  89. *
  90. * @see Pico
  91. * @return Pico the plugins instance of Pico
  92. */
  93. public function getPico();
  94. }