Loading automatic_updates_extensions/src/Form/UpdaterForm.php +18 −2 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ use Drupal\automatic_updates_extensions\ExtensionUpdater; use Drupal\Core\Batch\BatchBuilder; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\State\StateInterface; use Drupal\Core\Messenger\MessengerInterface; use Drupal\Core\Render\RendererInterface; use Drupal\Core\Url; Loading Loading @@ -41,6 +42,13 @@ final class UpdaterForm extends FormBase { */ private $eventDispatcher; /** * The state service. * * @var \Drupal\Core\State\StateInterface */ private $state; /** * The renderer service. * Loading @@ -55,7 +63,8 @@ final class UpdaterForm extends FormBase { return new static( $container->get('automatic_updates_extensions.updater'), $container->get('event_dispatcher'), $container->get('renderer') $container->get('renderer'), $container->get('state') ); } Loading @@ -68,11 +77,14 @@ final class UpdaterForm extends FormBase { * The extension event dispatcher service. * @param \Drupal\Core\Render\RendererInterface $renderer * The renderer service. * @param \Drupal\Core\State\StateInterface $state * The state service. */ public function __construct(ExtensionUpdater $extension_updater, EventDispatcherInterface $event_dispatcher, RendererInterface $renderer) { public function __construct(ExtensionUpdater $extension_updater, EventDispatcherInterface $event_dispatcher, RendererInterface $renderer, StateInterface $state) { $this->extensionUpdater = $extension_updater; $this->eventDispatcher = $event_dispatcher; $this->renderer = $renderer; $this->state = $state; } /** Loading Loading @@ -141,6 +153,10 @@ final class UpdaterForm extends FormBase { $form['actions'] = $this->actions($form_state); } $form['last_check'] = [ '#theme' => 'update_last_check', '#last' => $this->state->get('update.last_check', 0), ]; return $form; } Loading automatic_updates_extensions/tests/src/Functional/UpdaterFormTest.php +11 −3 Original line number Diff line number Diff line Loading @@ -234,13 +234,12 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { $user = $this->createUser(['administer site configuration']); $this->drupalLogin($user); $this->setProjectInstalledVersion(['semver_test' => '8.1.0']); $this->checkForUpdates(); $this->drupalGet('admin/reports/updates/automatic-update-extensions'); $assert->pageTextContains('Access Denied'); $assert->pageTextNotContains('Automatic Updates Form'); $user = $this->createUser(['administer software updates']); $user = $this->createUser(['administer software updates', 'administer site configuration']); $this->drupalLogin($user); $this->drupalGet('admin/reports/updates/automatic-update-extensions'); $this->checkForUpdates(); $this->assertTableShowsUpdates('Semver Test', '8.1.0', '8.1.1'); $assert->pageTextContains('Automatic Updates Form'); $assert->buttonExists('Update'); Loading @@ -262,6 +261,15 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { $this->assertNoUpdates(); } /** * {@inheritdoc} */ protected function checkForUpdates(): void { $this->drupalGet('/admin/modules/automatic-update-extensions'); $this->clickLink('Check manually'); $this->checkForMetaRefresh(); } /** * Test the form for errors. */ Loading Loading
automatic_updates_extensions/src/Form/UpdaterForm.php +18 −2 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ use Drupal\automatic_updates_extensions\ExtensionUpdater; use Drupal\Core\Batch\BatchBuilder; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\State\StateInterface; use Drupal\Core\Messenger\MessengerInterface; use Drupal\Core\Render\RendererInterface; use Drupal\Core\Url; Loading Loading @@ -41,6 +42,13 @@ final class UpdaterForm extends FormBase { */ private $eventDispatcher; /** * The state service. * * @var \Drupal\Core\State\StateInterface */ private $state; /** * The renderer service. * Loading @@ -55,7 +63,8 @@ final class UpdaterForm extends FormBase { return new static( $container->get('automatic_updates_extensions.updater'), $container->get('event_dispatcher'), $container->get('renderer') $container->get('renderer'), $container->get('state') ); } Loading @@ -68,11 +77,14 @@ final class UpdaterForm extends FormBase { * The extension event dispatcher service. * @param \Drupal\Core\Render\RendererInterface $renderer * The renderer service. * @param \Drupal\Core\State\StateInterface $state * The state service. */ public function __construct(ExtensionUpdater $extension_updater, EventDispatcherInterface $event_dispatcher, RendererInterface $renderer) { public function __construct(ExtensionUpdater $extension_updater, EventDispatcherInterface $event_dispatcher, RendererInterface $renderer, StateInterface $state) { $this->extensionUpdater = $extension_updater; $this->eventDispatcher = $event_dispatcher; $this->renderer = $renderer; $this->state = $state; } /** Loading Loading @@ -141,6 +153,10 @@ final class UpdaterForm extends FormBase { $form['actions'] = $this->actions($form_state); } $form['last_check'] = [ '#theme' => 'update_last_check', '#last' => $this->state->get('update.last_check', 0), ]; return $form; } Loading
automatic_updates_extensions/tests/src/Functional/UpdaterFormTest.php +11 −3 Original line number Diff line number Diff line Loading @@ -234,13 +234,12 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { $user = $this->createUser(['administer site configuration']); $this->drupalLogin($user); $this->setProjectInstalledVersion(['semver_test' => '8.1.0']); $this->checkForUpdates(); $this->drupalGet('admin/reports/updates/automatic-update-extensions'); $assert->pageTextContains('Access Denied'); $assert->pageTextNotContains('Automatic Updates Form'); $user = $this->createUser(['administer software updates']); $user = $this->createUser(['administer software updates', 'administer site configuration']); $this->drupalLogin($user); $this->drupalGet('admin/reports/updates/automatic-update-extensions'); $this->checkForUpdates(); $this->assertTableShowsUpdates('Semver Test', '8.1.0', '8.1.1'); $assert->pageTextContains('Automatic Updates Form'); $assert->buttonExists('Update'); Loading @@ -262,6 +261,15 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { $this->assertNoUpdates(); } /** * {@inheritdoc} */ protected function checkForUpdates(): void { $this->drupalGet('/admin/modules/automatic-update-extensions'); $this->clickLink('Check manually'); $this->checkForMetaRefresh(); } /** * Test the form for errors. */ Loading