Commit a824bb65 authored by Phil Norton's avatar Phil Norton
Browse files

Issue #3272786: Correcting some minor code errors and spelling. Improving test...

Issue #3272786: Correcting some minor code errors and spelling. Improving test of delete all functionality.
parent c5511547
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -18,4 +18,4 @@ services:

  session_inspector.session_deletion:
    class: Drupal\session_inspector\SessionDeletion
    arguments: ['@entity_type.manager', '@session_inspector', '@database', '@event_dispatcher']
    arguments: ['@session_inspector', '@database', '@event_dispatcher']
+3 −3
Original line number Diff line number Diff line
@@ -132,13 +132,13 @@ class UserSessionInspector extends ControllerBase {
      $browserFormatter = $this->browserFormatManager->createInstance($browserFormat);

      $dateIntervalInclude = $config->get('date_interval_include') ?? TRUE;
      $dateFromat = $config->get('date_format') ?? 'medium';
      $dateFormat = $config->get('date_format') ?? 'medium';

      foreach ($sessions as $i => $session) {
        $rows[] = [
          $this->sessionInspector->isCurrentSession($session['sid']) ? $this->t('YES') : '',
          $hostnameFormatter->formatHostname($session['hostname']),
          $this->formatTimestamp($session['timestamp'], $dateFromat, $dateIntervalInclude),
          $this->formatTimestamp($session['timestamp'], $dateFormat, $dateIntervalInclude),
          $browserFormatter->formatBrowser($session['browser']),
          [
            'data' => $this->formatDeleteLink($user, $session['sid']),
@@ -174,7 +174,7 @@ class UserSessionInspector extends ControllerBase {
    $build['delete_all_sessions_link'] = [
      '#type' => 'link',
      '#url' => Url::fromRoute('session_inspector.delete_all', ['user' => $user->id()]),
      '#title' => $this->t('Delete all sessions'),
      '#title' => $this->t('Delete all other sessions'),
      '#attributes' => [
        'class' => [
          'button',
+2 −2
Original line number Diff line number Diff line
@@ -67,14 +67,14 @@ class DeleteAllSessionsForm extends ConfirmFormBase {
   * {@inheritDoc}
   */
  public function getDescription() {
    return $this->t('This action will delete all other active sessions and cannot be undone.');
    return $this->t('This action will delete all other active sessions and cannot be undone. You will still be logged in with the current session once complete.');
  }

  /**
   * {@inheritDoc}
   */
  public function getQuestion() {
    return $this->t('Delete all sessions?');
    return $this->t('Delete all other sessions?');
  }

  /**
+1 −1
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ class DeleteSessionForm extends ConfirmFormBase {
   * {@inheritDoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    // Destroy the session.
    // Delete the session.
    $this->deleteAllSessionsService->deleteSession($this->sessionId);

    // Redirect the user back to the session list.
+1 −12
Original line number Diff line number Diff line
@@ -3,7 +3,6 @@
namespace Drupal\session_inspector;

use Drupal\Core\Database\Connection;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\session_inspector\Event\SessionEvent;
use Drupal\session_inspector\Event\SessionInspectorEvents;
use Drupal\user\Entity\User;
@@ -16,13 +15,6 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
 */
class SessionDeletion implements SessionDeletionInterface {

  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * The SessionInspector service.
   *
@@ -47,8 +39,6 @@ class SessionDeletion implements SessionDeletionInterface {
  /**
   * Constructs a SessionDeletion object.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
   *   The entity type manager.
   * @param \Drupal\session_inspector\SessionInspectorInterface $sessionInspector
   *   The SessionInspector service.
   * @param \Drupal\Core\Database\Connection $database
@@ -56,8 +46,7 @@ class SessionDeletion implements SessionDeletionInterface {
   * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
   *   The event dispatcher.
   */
  public function __construct(EntityTypeManagerInterface $entityTypeManager, SessionInspectorInterface $sessionInspector, Connection $database, EventDispatcherInterface $event_dispatcher) {
    $this->entityTypeManager = $entityTypeManager;
  public function __construct(SessionInspectorInterface $sessionInspector, Connection $database, EventDispatcherInterface $event_dispatcher) {
    $this->sessionInspector = $sessionInspector;
    $this->database = $database;
    $this->eventDispatcher = $event_dispatcher;
Loading