KernelInterface.php 4.4 KB

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