InstallerKernel.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace Drupal\Core\Installer;
  3. use Drupal\Core\DrupalKernel;
  4. /**
  5. * Extend DrupalKernel to handle force some kernel behaviors.
  6. */
  7. class InstallerKernel extends DrupalKernel {
  8. /**
  9. * {@inheritdoc}
  10. */
  11. protected function initializeContainer() {
  12. // Always force a container rebuild.
  13. $this->containerNeedsRebuild = TRUE;
  14. // Ensure the InstallerKernel's container is not dumped.
  15. $this->allowDumping = FALSE;
  16. $container = parent::initializeContainer();
  17. return $container;
  18. }
  19. /**
  20. * Reset the bootstrap config storage.
  21. *
  22. * Use this from a database driver runTasks() if the method overrides the
  23. * bootstrap config storage. Normally the bootstrap config storage is not
  24. * re-instantiated during a single install request. Most drivers will not
  25. * need this method.
  26. *
  27. * @see \Drupal\Core\Database\Install\Tasks::runTasks()
  28. */
  29. public function resetConfigStorage() {
  30. $this->configStorage = NULL;
  31. }
  32. /**
  33. * Returns the active configuration storage used during early install.
  34. *
  35. * This override changes the visibility so that the installer can access
  36. * config storage before the container is properly built.
  37. *
  38. * @return \Drupal\Core\Config\StorageInterface
  39. * The config storage.
  40. */
  41. public function getConfigStorage() {
  42. return parent::getConfigStorage();
  43. }
  44. /**
  45. * {@inheritdoc}
  46. */
  47. public function getInstallProfile() {
  48. global $install_state;
  49. if ($install_state && empty($install_state['installation_finished'])) {
  50. // If the profile has been selected return it.
  51. if (isset($install_state['parameters']['profile'])) {
  52. $profile = $install_state['parameters']['profile'];
  53. }
  54. else {
  55. $profile = NULL;
  56. }
  57. }
  58. else {
  59. $profile = parent::getInstallProfile();
  60. }
  61. return $profile;
  62. }
  63. /**
  64. * Returns TRUE if a Drupal installation is currently being attempted.
  65. *
  66. * @return bool
  67. * TRUE if the installation is currently being attempted.
  68. */
  69. public static function installationAttempted() {
  70. // This cannot rely on the MAINTENANCE_MODE constant, since that would
  71. // prevent tests from using the non-interactive installer, in which case
  72. // Drupal only happens to be installed within the same request, but
  73. // subsequently executed code does not involve the installer at all.
  74. // @see install_drupal()
  75. return isset($GLOBALS['install_state']) && empty($GLOBALS['install_state']['installation_finished']);
  76. }
  77. }