Commit 5d681486 authored by Ken Rickard's avatar Ken Rickard
Browse files

Issue #3307172 by omkar-pd, agentrickard: Add message on uiser assignment

parent 9924d37b
Loading
Loading
Loading
Loading
+16 −2
Changes for src/Form/AssignUserForm.php: 16 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Config\Entity\ConfigEntityStorageInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\user\UserInterface;
use Drupal\workbench_access\AccessControlHierarchyInterface;
use Drupal\workbench_access\RoleSectionStorageInterface;
@@ -65,6 +66,13 @@ class AssignUserForm extends FormBase {
   */
  protected $roleSectionStorage;

  /**
   * The Drupal messenger service.
   *
   * @var \Drupal\Core\Messenger\MessengerInterface
   */
  protected $messenger;

  /**
   * Constructs the form object.
   *
@@ -78,13 +86,16 @@ class AssignUserForm extends FormBase {
   *   The user section storage service.
   * @param \Drupal\workbench_access\RoleSectionStorageInterface $role_section_storage
   *   The role section storage service.
   * @param \Drupal\Core\Messenger\MessengerInterface $messenger
   *   The Drupal messenger service.
   */
  public function __construct(WorkbenchAccessManagerInterface $manager, ConfigEntityStorageInterface $scheme_storage, SectionAssociationStorageInterface $section_storage, UserSectionStorageInterface $user_section_storage, RoleSectionStorageInterface $role_section_storage) {
  public function __construct(WorkbenchAccessManagerInterface $manager, ConfigEntityStorageInterface $scheme_storage, SectionAssociationStorageInterface $section_storage, UserSectionStorageInterface $user_section_storage, RoleSectionStorageInterface $role_section_storage, MessengerInterface $messenger) {
    $this->manager = $manager;
    $this->schemeStorage = $scheme_storage;
    $this->sectionStorage = $section_storage;
    $this->userSectionStorage = $user_section_storage;
    $this->roleSectionStorage = $role_section_storage;
    $this->messenger = $messenger;
  }

  /**
@@ -96,7 +107,8 @@ class AssignUserForm extends FormBase {
      $container->get('entity_type.manager')->getStorage('access_scheme'),
      $container->get('entity_type.manager')->getStorage('section_association'),
      $container->get('workbench_access.user_section_storage'),
      $container->get('workbench_access.role_section_storage')
      $container->get('workbench_access.role_section_storage'),
      $container->get('messenger')
    );
  }

@@ -212,6 +224,8 @@ class AssignUserForm extends FormBase {
      }));
      $this->userSectionStorage->removeUser($item['scheme'], $this->user, $remove_sections);
    }

    $this->messenger()->addMessage($this->t('Section assignments updated successfully.'));
  }

  /**