plugin.php.twig 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace Grav\Plugin;
  3. use Composer\Autoload\ClassLoader;
  4. use Grav\Common\Plugin;
  5. /**
  6. * Class {{ component.name|camelize }}Plugin
  7. * @package Grav\Plugin
  8. */
  9. class {{ component.name|camelize }}Plugin extends Plugin
  10. {
  11. /**
  12. * @return array
  13. *
  14. * The getSubscribedEvents() gives the core a list of events
  15. * that the plugin wants to listen to. The key of each
  16. * array section is the event that the plugin listens to
  17. * and the value (in the form of an array) contains the
  18. * callable (or function) as well as the priority. The
  19. * higher the number the higher the priority.
  20. */
  21. public static function getSubscribedEvents(): array
  22. {
  23. return [
  24. 'onPluginsInitialized' => [
  25. // Uncomment following line when plugin requires Grav < 1.7
  26. // ['autoload', 100000],
  27. ['onPluginsInitialized', 0]
  28. ]
  29. ];
  30. }
  31. /**
  32. * Composer autoload
  33. *
  34. * @return ClassLoader
  35. */
  36. public function autoload(): ClassLoader
  37. {
  38. return require __DIR__ . '/vendor/autoload.php';
  39. }
  40. /**
  41. * Initialize the plugin
  42. */
  43. public function onPluginsInitialized(): void
  44. {
  45. // Don't proceed if we are in the admin plugin
  46. if ($this->isAdmin()) {
  47. return;
  48. }
  49. // Enable the main events we are interested in
  50. $this->enable([
  51. // Put your main events here
  52. ]);
  53. }
  54. }