Skouter mortgage estimates. Web application with view written in PHP and Vue, but controller and models in Go.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

plugin.php.twig 1.9 KiB

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