Skip to content
Snippets Groups Projects
Commit 08314d84 authored by dpi's avatar dpi
Browse files

Add event type cache invalidation to event manager.

parent a1ef8980
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,7 @@ use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\rng\Exception\InvalidEventException;
use Drupal\Core\Cache\Cache;
/**
* Event manager for RNG.
......@@ -112,4 +113,24 @@ class EventManager implements EventManagerInterface {
return $entity_type_bundles;
}
/**
* {@inheritdoc}
*/
function invalidateEventTypes() {
$event_types = $this->getEventTypes();
foreach ($event_types as $i => $bundles) {
foreach ($bundles as $b => $event_type) {
/** @var \Drupal\rng\EventTypeInterface $event_type */
$this->invalidateEventType($event_type);
}
}
}
/**
* {@inheritdoc}
*/
function invalidateEventType(EventTypeInterface $event_type) {
Cache::invalidateTags($event_type->getCacheTags());
}
}
......@@ -118,4 +118,16 @@ interface EventManagerInterface {
*/
function getEventTypes();
/**
* Invalidate cache for events types.
*/
function invalidateEventTypes();
/**
* Invalidate cache for an event type.
*
* @param \Drupal\rng\EventTypeInterface $event_type
* An event type.
*/
function invalidateEventType(EventTypeInterface $event_type);
}
......@@ -15,7 +15,6 @@ use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\rng\EventManagerInterface;
use Drupal\rng\RNGConditionInterface;
use Drupal\Core\Cache\Cache;
/**
* Form for event type access defaults.
......@@ -282,7 +281,7 @@ class EventTypeAccessDefaultsForm extends EntityForm {
}
drupal_set_message($this->t('Event type access defaults saved.'));
Cache::invalidateTags($event_type->getCacheTags());
$this->eventManager->invalidateEventType($event_type);
}
/**
......
......@@ -15,7 +15,6 @@ use Drupal\rng\EventTypeRuleInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Cache\Cache;
/**
* Configure event settings.
......@@ -167,7 +166,7 @@ class EventTypeRuleComponentEdit extends FormBase {
$this->eventTypeRule->getEventBundle()
);
Cache::invalidateTags($event_type->getCacheTags());
$this->eventManager->invalidateEventType($event_type);
}
}
......@@ -9,6 +9,8 @@ namespace Drupal\rng\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\rng\EventManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Render\Element;
use Drupal\user\Entity\Role;
use Drupal\Core\Session\AccountInterface;
......@@ -18,6 +20,32 @@ use Drupal\Core\Session\AccountInterface;
*/
class PluginConditionSettingsForm extends FormBase {
/**
* The RNG event manager.
*
* @var \Drupal\rng\EventManagerInterface
*/
protected $eventManager;
/**
* Constructs a new PluginConditionSettingsForm object.
*
* @param \Drupal\rng\EventManagerInterface $event_manager
* The RNG event manager.
*/
public function __construct(EventManagerInterface $event_manager) {
$this->eventManager = $event_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('rng.event_manager')
);
}
/**
* {@inheritdoc}
*/
......@@ -72,6 +100,7 @@ class PluginConditionSettingsForm extends FormBase {
->setThirdPartySetting('rng', 'condition_rng_role', (boolean) $checked)
->save();
}
$this->eventManager->invalidateEventTypes();
drupal_set_message(t('Updated condition plugin settings.'));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment