PluginInterface.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. const VALID_HOOKS = ['routes', 'bootstrap', 'console', 'middleware'];
  23. /**
  24. * Get the name of this plugin.
  25. *
  26. * @return string
  27. */
  28. public function getName();
  29. /**
  30. * Get the filesystem path to this plugin
  31. *
  32. * @return string
  33. */
  34. public function getPath();
  35. /**
  36. * Get the filesystem path to configuration for this plugin
  37. *
  38. * @return string
  39. */
  40. public function getConfigPath();
  41. /**
  42. * Get the filesystem path to configuration for this plugin
  43. *
  44. * @return string
  45. */
  46. public function getClassPath();
  47. /**
  48. * Load all the application configuration and bootstrap logic.
  49. *
  50. * The default implementation of this method will include the `config/bootstrap.php` in the plugin if it exist. You
  51. * can override this method to replace that behavior.
  52. *
  53. * The host application is provided as an argument. This allows you to load additional
  54. * plugin dependencies, or attach events.
  55. *
  56. * @param \Cake\Core\PluginApplicationInterface $app The host application
  57. * @return void
  58. */
  59. public function bootstrap(PluginApplicationInterface $app);
  60. /**
  61. * Add console commands for the plugin.
  62. *
  63. * @param \Cake\Console\CommandCollection $commands The command collection to update
  64. * @return \Cake\Console\CommandCollection
  65. */
  66. public function console($commands);
  67. /**
  68. * Add middleware for the plugin.
  69. *
  70. * @param \Cake\Http\MiddlewareQueue $middleware The middleware queue to update.
  71. * @return \Cake\Http\MiddlewareQueue
  72. */
  73. public function middleware($middleware);
  74. /**
  75. * Add routes for the plugin.
  76. *
  77. * The default implementation of this method will include the `config/routes.php` in the plugin if it exists. You
  78. * can override this method to replace that behavior.
  79. *
  80. * @param \Cake\Routing\RouteBuilder $routes The route builder to update.
  81. * @return void
  82. */
  83. public function routes($routes);
  84. /**
  85. * Disables the named hook
  86. *
  87. * @param string $hook The hook to disable
  88. * @return $this
  89. */
  90. public function disable($hook);
  91. /**
  92. * Enables the named hook
  93. *
  94. * @param string $hook The hook to disable
  95. * @return $this
  96. */
  97. public function enable($hook);
  98. /**
  99. * Check if the named hook is enabled
  100. *
  101. * @param string $hook The hook to check
  102. * @return bool
  103. */
  104. public function isEnabled($hook);
  105. }