PluginInterface.php 3.1 KB

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