refreshless-8.x-1.x-dev/refreshless.install
refreshless.install
<?php
declare(strict_types=1);
use Drupal\Core\Link;
use Drupal\Core\Url;
/**
* Implements \hook_requirements().
*/
function refreshless_requirements(string $phase): array {
$requirements = [];
// @todo Remove when https://www.drupal.org/project/refreshless/issues/3519784
// is fixed.
if (
\in_array($phase, ['install', 'runtime']) &&
\Drupal::service('module_handler')->moduleExists('big_pipe') === true
) {
$requirements['refreshless_bigpipe'] = [
'title' => \t('RefreshLess - BigPipe compatibility'),
'severity' => REQUIREMENT_ERROR,
'description' => \t(
'RefreshLess is not yet compatible with the BigPipe module. Please uninstall BigPipe to use RefreshLess. See @issueLink if you\'d like to help out with this.',
['@issueLink' => (new Link(\t(
'issue #3519784',
), Url::fromUri(
'https://www.drupal.org/project/refreshless/issues/3519784',
)))->toString()],
),
];
}
return $requirements;
}
/**
* Implements \hook_install().
*
* Installs the 'refreshless_turbo' module if not already installed as it's the
* only implementation currently and there's no UI/UX yet for indicating to
* users that they need to install it for RefreshLess to work.
*
* @todo Add kernel test for this?
*/
function refreshless_install(bool $isSyncing): void {
if (\Drupal::service('module_handler')->moduleExists(
'refreshless_turbo',
) === true) {
return;
}
\Drupal::service('module_installer')->install(['refreshless_turbo']);
\Drupal::service('messenger')->addStatus(\t(
'RefreshLess: installed Hotwire Turbo sub-module.',
));
}
/**
* Rebuild container for moving Ajax implementation to sub-module.
*/
function refreshless_update_10201(): void {
\Drupal::service('kernel')->invalidateContainer();
}
/**
* Rebuild libraries for addition of progress bar components.
*/
function refreshless_update_10202(): void {
\Drupal::service('library.discovery')->clearCachedDefinitions();
}
/**
* Install Hux and rebuild container for named aggregation hooks in root module.
*/
function refreshless_update_10203(): void {
\Drupal::service('module_installer')->install(['hux']);
\Drupal::service('kernel')->invalidateContainer();
}
/**
* Rebuild libraries for for switch to full SDC progress bar library use.
*/
function refreshless_update_10204(): void {
\Drupal::service('library.discovery')->clearCachedDefinitions();
}
/**
* Rebuild container for new page state factory service.
*/
function refreshless_update_10205(): void {
\Drupal::service('kernel')->invalidateContainer();
}
/**
* Rebuild container for factory services and value objects rework.
*/
function refreshless_update_10206(): void {
\Drupal::service('kernel')->invalidateContainer();
}
/**
* Rebuild components and install refreshless_preloader module.
*/
function refreshless_update_10207(): void {
\Drupal::service('plugin.manager.sdc')->clearCachedDefinitions();
\Drupal::service('module_installer')->install(['refreshless_preloader']);
}
/**
* Rebuild components and libraries for debug logging component port.
*/
function refreshless_update_10208(): void {
\Drupal::service('plugin.manager.sdc')->clearCachedDefinitions();
\Drupal::service('library.discovery')->clearCachedDefinitions();
}
