KernelInterface.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\HttpKernel;
  11. use Symfony\Component\DependencyInjection\ContainerInterface;
  12. use Symfony\Component\HttpKernel\HttpKernelInterface;
  13. use Symfony\Component\HttpKernel\Bundle\BundleInterface;
  14. use Symfony\Component\Config\Loader\LoaderInterface;
  15. /**
  16. * The Kernel is the heart of the Symfony system.
  17. *
  18. * It manages an environment made of bundles.
  19. *
  20. * @author Fabien Potencier <fabien@symfony.com>
  21. *
  22. * @api
  23. */
  24. interface KernelInterface extends HttpKernelInterface, \Serializable
  25. {
  26. /**
  27. * Returns an array of bundles to registers.
  28. *
  29. * @return BundleInterface[] An array of bundle instances.
  30. *
  31. * @api
  32. */
  33. public function registerBundles();
  34. /**
  35. * Loads the container configuration
  36. *
  37. * @param LoaderInterface $loader A LoaderInterface instance
  38. *
  39. * @api
  40. */
  41. public function registerContainerConfiguration(LoaderInterface $loader);
  42. /**
  43. * Boots the current kernel.
  44. *
  45. * @api
  46. */
  47. public function boot();
  48. /**
  49. * Shutdowns the kernel.
  50. *
  51. * This method is mainly useful when doing functional testing.
  52. *
  53. * @api
  54. */
  55. public function shutdown();
  56. /**
  57. * Gets the registered bundle instances.
  58. *
  59. * @return BundleInterface[] An array of registered bundle instances
  60. *
  61. * @api
  62. */
  63. public function getBundles();
  64. /**
  65. * Checks if a given class name belongs to an active bundle.
  66. *
  67. * @param string $class A class name
  68. *
  69. * @return Boolean true if the class belongs to an active bundle, false otherwise
  70. *
  71. * @api
  72. */
  73. public function isClassInActiveBundle($class);
  74. /**
  75. * Returns a bundle and optionally its descendants by its name.
  76. *
  77. * @param string $name Bundle name
  78. * @param Boolean $first Whether to return the first bundle only or together with its descendants
  79. *
  80. * @return BundleInterface|BundleInterface[] A BundleInterface instance or an array of BundleInterface instances if $first is false
  81. *
  82. * @throws \InvalidArgumentException when the bundle is not enabled
  83. *
  84. * @api
  85. */
  86. public function getBundle($name, $first = true);
  87. /**
  88. * Returns the file path for a given resource.
  89. *
  90. * A Resource can be a file or a directory.
  91. *
  92. * The resource name must follow the following pattern:
  93. *
  94. * @BundleName/path/to/a/file.something
  95. *
  96. * where BundleName is the name of the bundle
  97. * and the remaining part is the relative path in the bundle.
  98. *
  99. * If $dir is passed, and the first segment of the path is Resources,
  100. * this method will look for a file named:
  101. *
  102. * $dir/BundleName/path/without/Resources
  103. *
  104. * @param string $name A resource name to locate
  105. * @param string $dir A directory where to look for the resource first
  106. * @param Boolean $first Whether to return the first path or paths for all matching bundles
  107. *
  108. * @return string|array The absolute path of the resource or an array if $first is false
  109. *
  110. * @throws \InvalidArgumentException if the file cannot be found or the name is not valid
  111. * @throws \RuntimeException if the name contains invalid/unsafe characters
  112. *
  113. * @api
  114. */
  115. public function locateResource($name, $dir = null, $first = true);
  116. /**
  117. * Gets the name of the kernel
  118. *
  119. * @return string The kernel name
  120. *
  121. * @api
  122. */
  123. public function getName();
  124. /**
  125. * Gets the environment.
  126. *
  127. * @return string The current environment
  128. *
  129. * @api
  130. */
  131. public function getEnvironment();
  132. /**
  133. * Checks if debug mode is enabled.
  134. *
  135. * @return Boolean true if debug mode is enabled, false otherwise
  136. *
  137. * @api
  138. */
  139. public function isDebug();
  140. /**
  141. * Gets the application root dir.
  142. *
  143. * @return string The application root dir
  144. *
  145. * @api
  146. */
  147. public function getRootDir();
  148. /**
  149. * Gets the current container.
  150. *
  151. * @return ContainerInterface A ContainerInterface instance
  152. *
  153. * @api
  154. */
  155. public function getContainer();
  156. /**
  157. * Gets the request start time (not available if debug is disabled).
  158. *
  159. * @return integer The request start timestamp
  160. *
  161. * @api
  162. */
  163. public function getStartTime();
  164. /**
  165. * Gets the cache directory.
  166. *
  167. * @return string The cache directory
  168. *
  169. * @api
  170. */
  171. public function getCacheDir();
  172. /**
  173. * Gets the log directory.
  174. *
  175. * @return string The log directory
  176. *
  177. * @api
  178. */
  179. public function getLogDir();
  180. /**
  181. * Gets the charset of the application.
  182. *
  183. * @return string The charset
  184. *
  185. * @api
  186. */
  187. public function getCharset();
  188. }