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

Various improvements to RNGSelectionBase.

Changed RNGSelectionBase base class to non-deprecated class.
Added 'rng_register' tag to queries extending RNGSelectionBase.
Removed parent constructor calling deprecated parent $connection param.
Moved condition plugin instance creation so type hinting works correctly.
parent 4e61d01d
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@
namespace Drupal\rng\Plugin\EntityReferenceSelection;
use Drupal\Core\Entity\Plugin\EntityReferenceSelection\SelectionBase;
use Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Session\AccountInterface;
......@@ -20,7 +20,7 @@ use \Drupal\Core\Entity\Query\QueryInterface;
/**
* Base RNG selection plugin.
*/
class RNGSelectionBase extends SelectionBase {
class RNGSelectionBase extends DefaultSelection {
/**
* The condition plugin manager.
......@@ -40,7 +40,7 @@ class RNGSelectionBase extends SelectionBase {
* The condition plugin manager.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler, AccountInterface $current_user, Connection $connection, EventManagerInterface $event_manager, ConditionManager $condition_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_manager, $module_handler, $current_user, $connection);
parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_manager, $module_handler, $current_user);
if (isset($this->configuration['handler_settings']['event_entity_type'], $this->configuration['handler_settings']['event_entity_id'])) {
$event = $this->entityManager->getStorage($this->configuration['handler_settings']['event_entity_type'])->load($this->configuration['handler_settings']['event_entity_id']);
......@@ -97,6 +97,7 @@ class RNGSelectionBase extends SelectionBase {
*/
protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
$query = parent::buildEntityQuery($match, $match_operator);
$query->addTag('rng_register');
$this->removeDuplicateRegistrants($query);
return $query;
}
......
......@@ -49,7 +49,8 @@ class UserRNGSelection extends RNGSelectionBase {
if ($this->ruleGrantsOperation($rule, 'create')) {
foreach ($rule->getConditions() as $condition_storage) {
// Do not use condition if it cannot alter query.
if (($condition = $condition_storage->createInstance()) instanceof RNGConditionInterface) {
$condition = $condition_storage->createInstance();
if ($condition instanceof RNGConditionInterface) {
$condition_count++;
$condition->alterQuery($query);
}
......
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