PluginInterface.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  4. * Copyright 2005-2011, Cake Software Foundation, Inc. (https://cakefoundation.org)
  5. * Licensed under The MIT License
  6. * Redistributions of files must retain the above copyright notice.
  7. *
  8. * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  9. * @link https://cakephp.org CakePHP(tm) Project
  10. * @since 3.6.0
  11. * @license https://opensource.org/licenses/mit-license.php MIT License
  12. */
  13. namespace Cake\Core;
  14. /**
  15. * Plugin Interface
  16. */
  17. interface PluginInterface
  18. {
  19. /**
  20. * List of valid hooks.
  21. *
  22. * @var string[]
  23. */
  24. const VALID_HOOKS = ['routes', 'bootstrap', 'console', 'middleware'];
  25. /**
  26. * Get the name of this plugin.
  27. *
  28. * @return string
  29. */
  30. public function getName();
  31. /**
  32. * Get the filesystem path to this plugin
  33. *
  34. * @return string
  35. */
  36. public function getPath();
  37. /**
  38. * Get the filesystem path to configuration for this plugin
  39. *
  40. * @return string
  41. */
  42. public function getConfigPath();
  43. /**
  44. * Get the filesystem path to configuration for this plugin
  45. *
  46. * @return string
  47. */
  48. public function getClassPath();
  49. /**
  50. * Load all the application configuration and bootstrap logic.
  51. *
  52. * The default implementation of this method will include the `config/bootstrap.php` in the plugin if it exist. You
  53. * can override this method to replace that behavior.
  54. *
  55. * The host application is provided as an argument. This allows you to load additional
  56. * plugin dependencies, or attach events.
  57. *
  58. * @param \Cake\Core\PluginApplicationInterface $app The host application
  59. * @return void
  60. */
  61. public function bootstrap(PluginApplicationInterface $app);
  62. /**
  63. * Add console commands for the plugin.
  64. *
  65. * @param \Cake\Console\CommandCollection $commands The command collection to update
  66. * @return \Cake\Console\CommandCollection
  67. */
  68. public function console($commands);
  69. /**
  70. * Add middleware for the plugin.
  71. *
  72. * @param \Cake\Http\MiddlewareQueue $middleware The middleware queue to update.
  73. * @return \Cake\Http\MiddlewareQueue
  74. */
  75. public function middleware($middleware);
  76. /**
  77. * Add routes for the plugin.
  78. *
  79. * The default implementation of this method will include the `config/routes.php` in the plugin if it exists. You
  80. * can override this method to replace that behavior.
  81. *
  82. * @param \Cake\Routing\RouteBuilder $routes The route builder to update.
  83. * @return void
  84. */
  85. public function routes($routes);
  86. /**
  87. * Disables the named hook
  88. *
  89. * @param string $hook The hook to disable
  90. * @return $this
  91. */
  92. public function disable($hook);
  93. /**
  94. * Enables the named hook
  95. *
  96. * @param string $hook The hook to disable
  97. * @return $this
  98. */
  99. public function enable($hook);
  100. /**
  101. * Check if the named hook is enabled
  102. *
  103. * @param string $hook The hook to check
  104. * @return bool
  105. */
  106. public function isEnabled($hook);
  107. }