Invalidate the user_role:farm_account_admin cache tag when the account admin settings form is submitted.
This commit is contained in:
parent
c3742becc1
commit
673446c284
|
@ -2,8 +2,11 @@
|
|||
|
||||
namespace Drupal\farm_role_account_admin\Form;
|
||||
|
||||
use Drupal\Core\Cache\CacheTagsInvalidatorInterface;
|
||||
use Drupal\Core\Config\ConfigFactoryInterface;
|
||||
use Drupal\Core\Form\ConfigFormBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Provides a settings form for the Account Admin Role module.
|
||||
|
@ -17,6 +20,36 @@ class AccountAdminSettingsForm extends ConfigFormbase {
|
|||
*/
|
||||
const SETTINGS = 'farm_role_account_admin.settings';
|
||||
|
||||
/**
|
||||
* The cache tags invalidator.
|
||||
*
|
||||
* @var \Drupal\Core\Cache\CacheTagsInvalidatorInterface
|
||||
*/
|
||||
protected $cacheTagsInvalidator;
|
||||
|
||||
/**
|
||||
* Constructs a \Drupal\system\ConfigFormBase object.
|
||||
*
|
||||
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
|
||||
* The factory for configuration objects.
|
||||
* @param \Drupal\Core\Cache\CacheTagsInvalidatorInterface $cache_tags_invalidator
|
||||
* The cache tags invalidator.
|
||||
*/
|
||||
public function __construct(ConfigFactoryInterface $config_factory, CacheTagsInvalidatorInterface $cache_tags_invalidator) {
|
||||
$this->setConfigFactory($config_factory);
|
||||
$this->cacheTagsInvalidator = $cache_tags_invalidator;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('config.factory'),
|
||||
$container->get('cache_tags.invalidator'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -57,6 +90,9 @@ class AccountAdminSettingsForm extends ConfigFormbase {
|
|||
->set('allow_peer_role_assignment', $form_state->getValue('allow_peer_role_assignment'))
|
||||
->save();
|
||||
|
||||
// Invalidate the user_role:farm_account_admin cache tag.
|
||||
$this->cacheTagsInvalidator->invalidateTags(['user_role:farm_account_admin']);
|
||||
|
||||
parent::submitForm($form, $form_state);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue