PicoPluginInterface.php.txt 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 PicoPluginInterface. 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. * PicoPluginInterface 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. * @param boolean $enabled enable (true) or disable (false) this plugin
  47. * @param boolean $recursive when true, enable or disable recursively
  48. * In other words, if you enable a plugin, all required plugins are
  49. * enabled, too. When disabling a plugin, all depending plugins are
  50. * disabled likewise. Recursive operations are only performed as long
  51. * as a plugin wasn't enabled/disabled manually. This parameter is
  52. * optional and defaults to true.
  53. * @param boolean $auto enable or disable to fulfill a dependency
  54. * This parameter is optional and defaults to false.
  55. * @return void
  56. * @throws RuntimeException thrown when a dependency fails
  57. */
  58. public function setEnabled($enabled, $recursive = true, $auto = false);
  59. /**
  60. * Returns true if this plugin is enabled, false otherwise
  61. *
  62. * @return boolean plugin is enabled (true) or disabled (false)
  63. */
  64. public function isEnabled();
  65. /**
  66. * Returns true if the plugin was ever enabled/disabled manually
  67. *
  68. * @return boolean plugin is in its default state (true), false otherwise
  69. */
  70. public function isStatusChanged();
  71. /**
  72. * Returns a list of names of plugins required by this plugin
  73. *
  74. * @return string[] required plugins
  75. */
  76. public function getDependencies();
  77. /**
  78. * Returns a list of plugins which depend on this plugin
  79. *
  80. * @return object[] dependant plugins
  81. */
  82. public function getDependants();
  83. /**
  84. * Returns the plugins instance of Pico
  85. *
  86. * @return Pico the plugins instance of Pico
  87. */
  88. public function getPico();
  89. }