KernelInterface.php 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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\Bundle\BundleInterface;
  13. use Symfony\Component\Config\Loader\LoaderInterface;
  14. /**
  15. * The Kernel is the heart of the Symfony system.
  16. *
  17. * It manages an environment made of application kernel and bundles.
  18. *
  19. * @author Fabien Potencier <fabien@symfony.com>
  20. */
  21. interface KernelInterface extends HttpKernelInterface, \Serializable
  22. {
  23. /**
  24. * Returns an array of bundles to register.
  25. *
  26. * @return iterable|BundleInterface[] An iterable of bundle instances
  27. */
  28. public function registerBundles();
  29. /**
  30. * Loads the container configuration.
  31. */
  32. public function registerContainerConfiguration(LoaderInterface $loader);
  33. /**
  34. * Boots the current kernel.
  35. */
  36. public function boot();
  37. /**
  38. * Shutdowns the kernel.
  39. *
  40. * This method is mainly useful when doing functional testing.
  41. */
  42. public function shutdown();
  43. /**
  44. * Gets the registered bundle instances.
  45. *
  46. * @return BundleInterface[] An array of registered bundle instances
  47. */
  48. public function getBundles();
  49. /**
  50. * Returns a bundle.
  51. *
  52. * @param string $name Bundle name
  53. *
  54. * @return BundleInterface A BundleInterface instance
  55. *
  56. * @throws \InvalidArgumentException when the bundle is not enabled
  57. */
  58. public function getBundle($name);
  59. /**
  60. * Returns the file path for a given bundle resource.
  61. *
  62. * A Resource can be a file or a directory.
  63. *
  64. * The resource name must follow the following pattern:
  65. *
  66. * "@BundleName/path/to/a/file.something"
  67. *
  68. * where BundleName is the name of the bundle
  69. * and the remaining part is the relative path in the bundle.
  70. *
  71. * If $dir is passed, and the first segment of the path is "Resources",
  72. * this method will look for a file named:
  73. *
  74. * $dir/<BundleName>/path/without/Resources
  75. *
  76. * before looking in the bundle resource folder.
  77. *
  78. * @param string $name A resource name to locate
  79. * @param string $dir A directory where to look for the resource first
  80. * @param bool $first Whether to return the first path or paths for all matching bundles
  81. *
  82. * @return string|array The absolute path of the resource or an array if $first is false
  83. *
  84. * @throws \InvalidArgumentException if the file cannot be found or the name is not valid
  85. * @throws \RuntimeException if the name contains invalid/unsafe characters
  86. */
  87. public function locateResource($name, $dir = null, $first = true);
  88. /**
  89. * Gets the name of the kernel.
  90. *
  91. * @return string The kernel name
  92. */
  93. public function getName();
  94. /**
  95. * Gets the environment.
  96. *
  97. * @return string The current environment
  98. */
  99. public function getEnvironment();
  100. /**
  101. * Checks if debug mode is enabled.
  102. *
  103. * @return bool true if debug mode is enabled, false otherwise
  104. */
  105. public function isDebug();
  106. /**
  107. * Gets the application root dir (path of the project's Kernel class).
  108. *
  109. * @return string The Kernel root dir
  110. */
  111. public function getRootDir();
  112. /**
  113. * Gets the current container.
  114. *
  115. * @return ContainerInterface A ContainerInterface instance
  116. */
  117. public function getContainer();
  118. /**
  119. * Gets the request start time (not available if debug is disabled).
  120. *
  121. * @return int The request start timestamp
  122. */
  123. public function getStartTime();
  124. /**
  125. * Gets the cache directory.
  126. *
  127. * @return string The cache directory
  128. */
  129. public function getCacheDir();
  130. /**
  131. * Gets the log directory.
  132. *
  133. * @return string The log directory
  134. */
  135. public function getLogDir();
  136. /**
  137. * Gets the charset of the application.
  138. *
  139. * @return string The charset
  140. */
  141. public function getCharset();
  142. }