From f90b74d2775a219178edb090149a89866e52c4f7 Mon Sep 17 00:00:00 2001 From: Lucas D Hedding Date: Tue, 21 Aug 2018 15:07:55 -0500 Subject: [PATCH 1/5] add waitlist features --- rng.field.defaults.inc | 23 ++++ rng.services.yml | 12 ++ .../RegistrationAccessControlHandler.php | 37 ++---- src/Entity/EventType.php | 2 + src/Entity/Registration.php | 3 +- src/Event/RegistrationAccessEvent.php | 110 ++++++++++++++++ src/Event/RegistrationEvent.php | 42 ++++++ src/Event/RegistrationEvents.php | 92 +++++++++++++ src/EventManagerInterface.php | 7 + src/EventMeta.php | 7 + src/EventMetaInterface.php | 8 ++ .../RegistrationWaitlistSubscriber.php | 69 ++++++++++ .../RngRegistrationCreationSubscriber.php | 123 ++++++++++++++++++ src/Form/EventTypeFieldMappingForm.php | 1 + src/RegistrationStorage.php | 65 +++++++++ 15 files changed, 576 insertions(+), 25 deletions(-) create mode 100644 src/Event/RegistrationAccessEvent.php create mode 100644 src/Event/RegistrationEvent.php create mode 100644 src/Event/RegistrationEvents.php create mode 100644 src/EventSubscriber/RegistrationWaitlistSubscriber.php create mode 100644 src/EventSubscriber/RngRegistrationCreationSubscriber.php create mode 100644 src/RegistrationStorage.php diff --git a/rng.field.defaults.inc b/rng.field.defaults.inc index cb49403..7ecce6d 100644 --- a/rng.field.defaults.inc +++ b/rng.field.defaults.inc @@ -52,6 +52,12 @@ function rng_add_event_field_storage($field_name, $entity_type) { ); break; + case EventManagerInterface::FIELD_WAIT_LIST: + $definition = [ + 'type' => 'boolean', + ]; + break; + case EventManagerInterface::FIELD_EMAIL_REPLY_TO: $definition = array( 'type' => 'email', @@ -127,6 +133,17 @@ function rng_event_field_config_definition($field_name) { ); break; + case EventManagerInterface::FIELD_WAIT_LIST: + $definition = [ + 'label' => 'Allow a wait list', + 'description' => t('Allow a waiting list for the event.'), + 'settings' => [ + 'on_label' => t('Allow a waiting list for this event'), + 'off_label' => t('Do not allow a waiting list for this event'), + ], + ]; + break; + case EventManagerInterface::FIELD_EMAIL_REPLY_TO: $definition = array( 'label' => t('Reply-to e-mail address'), @@ -235,6 +252,12 @@ function rng_add_event_form_display_defaults(EntityFormDisplayInterface $form_di )); break; + case EventManagerInterface::FIELD_WAIT_LIST: + $form_display->setComponent($field_name, [ + 'type' => 'boolean_checkbox', + ]); + break; + case EventManagerInterface::FIELD_EMAIL_REPLY_TO: $form_display->setComponent($field_name, array( 'type' => 'email_default', diff --git a/rng.services.yml b/rng.services.yml index 9109edf..4b9e838 100644 --- a/rng.services.yml +++ b/rng.services.yml @@ -78,3 +78,15 @@ services: arguments: ['@rng.event_route_context'] tags: - { name: cache.context } + rng.registration_creation_subscriber: + class: Drupal\rng\EventSubscriber\RngRegistrationCreationSubscriber + arguments: ['@rng.event_manager'] + tags: + - { name: event_subscriber } + rng.registration_waitlist_subscriber: + class: Drupal\rng\EventSubscriber\RegistrationWaitlistSubscriber + arguments: + - '@rng.event_manager' + - '@messenger' + tags: + - { name: event_subscriber } diff --git a/src/AccessControl/RegistrationAccessControlHandler.php b/src/AccessControl/RegistrationAccessControlHandler.php index 1035373..bedc4d7 100644 --- a/src/AccessControl/RegistrationAccessControlHandler.php +++ b/src/AccessControl/RegistrationAccessControlHandler.php @@ -4,7 +4,8 @@ use Drupal\Core\Access\AccessResult; use Drupal\Core\Entity\EntityAccessControlHandler; -use Drupal\rng\Entity\RegistrationType; +use Drupal\rng\Event\RegistrationAccessEvent; +use Drupal\rng\Event\RegistrationEvents; use Drupal\rng\RuleGrantsOperationTrait; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\EntityInterface; @@ -27,12 +28,20 @@ class RegistrationAccessControlHandler extends EntityAccessControlHandler { */ protected $eventManager; + /** + * The event dispatcher. + * + * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface + */ + protected $eventDispatcher; + /** * {@inheritdoc} */ public function __construct(EntityTypeInterface $entity_type) { parent::__construct($entity_type); $this->eventManager = \Drupal::service('rng.event_manager'); + $this->eventDispatcher = \Drupal::service('event_dispatcher'); } /** @@ -89,29 +98,9 @@ public function createAccess($entity_bundle = NULL, AccountInterface $account = $account = $this->prepareUser($account); try { - $event_meta = $this->eventManager->getMeta($event); - - // $entity_bundle is omitted for registration type list at - // $event_path/register - if ($entity_bundle && ($registration_type = RegistrationType::load($entity_bundle))) { - if (!$event_meta->registrationTypeIsValid($registration_type)) { - return $fail; - } - } - // There are no registration types configured. - elseif (!$event_meta->getRegistrationTypeIds()) { - return $fail; - } - - if (!$event_meta->isAcceptingRegistrations()) { - return $fail; - } - - if ($event_meta->remainingCapacity() == 0) { - return $fail; - } - - if (!$event_meta->canRegisterProxyIdentities()) { + $event = new RegistrationAccessEvent($entity_bundle, $account, $context); + $this->eventDispatcher->dispatch(RegistrationEvents::REGISTRATION_CREATE_ACCESS, $event); + if (!$event->isAccessAllowed()) { return $fail; } diff --git a/src/Entity/EventType.php b/src/Entity/EventType.php index 7b0abaa..0f627e4 100644 --- a/src/Entity/EventType.php +++ b/src/Entity/EventType.php @@ -116,6 +116,7 @@ class EventType extends ConfigEntityBase implements EventTypeInterface { EventManagerInterface::FIELD_REGISTRATION_GROUPS, EventManagerInterface::FIELD_STATUS, EventManagerInterface::FIELD_CAPACITY, + EventManagerInterface::FIELD_WAIT_LIST, EventManagerInterface::FIELD_EMAIL_REPLY_TO, EventManagerInterface::FIELD_ALLOW_DUPLICATE_REGISTRANTS, EventManagerInterface::FIELD_REGISTRATION_REGISTRANTS_MINIMUM, @@ -386,6 +387,7 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) { EventManagerInterface::FIELD_STATUS, EventManagerInterface::FIELD_ALLOW_DUPLICATE_REGISTRANTS, EventManagerInterface::FIELD_CAPACITY, + EventManagerInterface::FIELD_WAIT_LIST, EventManagerInterface::FIELD_EMAIL_REPLY_TO, EventManagerInterface::FIELD_REGISTRATION_TYPE, EventManagerInterface::FIELD_REGISTRATION_GROUPS, diff --git a/src/Entity/Registration.php b/src/Entity/Registration.php index cb11d99..89116c9 100644 --- a/src/Entity/Registration.php +++ b/src/Entity/Registration.php @@ -42,7 +42,8 @@ * "edit" = "Drupal\rng\Form\RegistrationForm", * "delete" = "Drupal\rng\Form\RegistrationDeleteForm", * "registrants" = "Drupal\rng\Form\RegistrationRegistrantEditForm" - * } + * }, + * "storage" = "Drupal\rng\RegistrationStorage", * }, * bundle_entity_type = "registration_type", * admin_permission = "administer registration entity", diff --git a/src/Event/RegistrationAccessEvent.php b/src/Event/RegistrationAccessEvent.php new file mode 100644 index 0000000..9cfa3bd --- /dev/null +++ b/src/Event/RegistrationAccessEvent.php @@ -0,0 +1,110 @@ +entityBundle = $entity_bundle; + $this->account = $account; + $this->context = $context; + } + + /** + * Get the entity bundle. + * + * @return string|null + * The entity bundle or NULL. + */ + public function getEntityBundle() { + return $this->entityBundle; + } + + /** + * Get the user session for which to check access. + * + * @return \Drupal\Core\Session\AccountInterface|null + * Gets the user session or NULL. + */ + public function getAccount() { + return $this->account; + } + + /** + * Get the context. + * + * @return array + * The context. + */ + public function getContext() { + return $this->context; + } + + /** + * Get if access is allowed. + * + * @return bool + * True if access is not denied, otherwise FALSE. + */ + public function isAccessAllowed() { + return $this->accessAllowed; + } + + /** + * Set access. + * + * @param bool $access + * Boolean if access is allowed. + */ + public function setAccess($access) { + $this->accessAllowed = $access; + } + +} diff --git a/src/Event/RegistrationEvent.php b/src/Event/RegistrationEvent.php new file mode 100644 index 0000000..5cac78f --- /dev/null +++ b/src/Event/RegistrationEvent.php @@ -0,0 +1,42 @@ +registration = $registration; + } + + /** + * Get the registration. + * + * @return \Drupal\rng\RegistrationInterface + * The registration. + */ + public function getRegistration() { + return $this->registration; + } + +} diff --git a/src/Event/RegistrationEvents.php b/src/Event/RegistrationEvents.php new file mode 100644 index 0000000..3be6eae --- /dev/null +++ b/src/Event/RegistrationEvents.php @@ -0,0 +1,92 @@ + 0 ? $remaining : 0; } + /** + * {@inheritdoc} + */ + public function allowWaitList() { + return (bool) $this->getEvent()->{EventManagerInterface::FIELD_WAIT_LIST}->value; + } + /** * {@inheritdoc} */ diff --git a/src/EventMetaInterface.php b/src/EventMetaInterface.php index e335acd..533cc84 100644 --- a/src/EventMetaInterface.php +++ b/src/EventMetaInterface.php @@ -137,6 +137,14 @@ public function getCapacity(); */ public function remainingCapacity(); + /** + * Checks if a registrant is allowed to register on a wait list on this event. + * + * @return bool + * Whether wait list registrations are allowed. + */ + public function allowWaitList(); + /** * Get minimum number of registrants allowed per registration. * diff --git a/src/EventSubscriber/RegistrationWaitlistSubscriber.php b/src/EventSubscriber/RegistrationWaitlistSubscriber.php new file mode 100644 index 0000000..2cb3502 --- /dev/null +++ b/src/EventSubscriber/RegistrationWaitlistSubscriber.php @@ -0,0 +1,69 @@ +rngEventManager = $rng_event_manager; + $this->messenger = $messenger; + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() { + $events[RegistrationEvents::REGISTRATION_INSERT] = ['onRegistrationInsert', -1]; + return $events; + } + + /** + * Notify the user if they are added to a wait list. + * + * @param \Drupal\rng\Event\RegistrationEvent $event + * The event. + * + * @throws \Drupal\rng\Exception\InvalidEventException + */ + public function onRegistrationInsert(RegistrationEvent $event) { + $meta = $this->rngEventManager->getMeta($event->getRegistration()->getEvent()); + if ($meta->allowWaitList() && $meta->remainingCapacity() < 1) { + $this->messenger->addStatus($this->t('Registration is at its capacity. You have been added to a waiting list.')); + } + } + +} diff --git a/src/EventSubscriber/RngRegistrationCreationSubscriber.php b/src/EventSubscriber/RngRegistrationCreationSubscriber.php new file mode 100644 index 0000000..48ccb6d --- /dev/null +++ b/src/EventSubscriber/RngRegistrationCreationSubscriber.php @@ -0,0 +1,123 @@ +rngEventManager = $rng_event_manager; + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() { + $events['rng.registration_create'][] = ['invalidEntityBundle']; + $events['rng.registration_create'][] = ['missingRegistrationType']; + $events['rng.registration_create'][] = ['acceptingRegistration']; + $events['rng.registration_create'][] = ['canRegisterProxies']; + // Setting this to a lower weight so it can potentially be easily skipped. + $events['rng.registration_create'][] = ['remainingCapacity', -1]; + return $events; + } + + /** + * Determines if there is an invalid entity bundle. + * + * @param \Drupal\rng\Event\RegistrationAccessEvent $event + */ + public function invalidEntityBundle(RegistrationAccessEvent $event) { + $meta = $this->getMeta($event->getContext()); + // $entity_bundle is omitted for registration type list at + // $event_path/register + if ($event->getEntityBundle() && ($registration_type = RegistrationType::load($event->getEntityBundle()))) { + if (!$meta->registrationTypeIsValid($registration_type)) { + $event->setAccess(FALSE); + } + } + } + + /** + * Determines if there are no registration types configured. + * + * @param \Drupal\rng\Event\RegistrationAccessEvent $event + */ + public function missingRegistrationType(RegistrationAccessEvent $event) { + $meta = $this->getMeta($event->getContext()); + if (!$meta->getRegistrationTypeIds()) { + $event->setAccess(FALSE); + } + } + + /** + * Determines if there is any remaining capacity. + * + * @param \Drupal\rng\Event\RegistrationAccessEvent $event + */ + public function acceptingRegistration(RegistrationAccessEvent $event) { + $meta = $this->getMeta($event->getContext()); + if (!$meta->isAcceptingRegistrations()) { + $event->setAccess(FALSE); + } + } + + /** + * Determines if there is any remaining capacity. + * + * @param \Drupal\rng\Event\RegistrationAccessEvent $event + */ + public function remainingCapacity(RegistrationAccessEvent $event) { + $meta = $this->getMeta($event->getContext()); + if (!$meta->allowWaitList() && $meta->remainingCapacity() < 1) { + $event->setAccess(FALSE); + } + } + + /** + * Determines if user can register proxies. + * + * @param \Drupal\rng\Event\RegistrationAccessEvent $event + */ + public function canRegisterProxies(RegistrationAccessEvent $event) { + $meta = $this->getMeta($event->getContext()); + if (!$meta->canRegisterProxyIdentities()) { + $event->setAccess(FALSE); + } + } + + /** + * Get the event meta. + * + * @param array $context + * + * @return \Drupal\rng\EventMetaInterface|null + * The event meta or NULL. + * + * @throws \Drupal\rng\Exception\InvalidEventException + */ + protected function getMeta(array $context) { + return $this->rngEventManager->getMeta($context['event']); + } + +} diff --git a/src/Form/EventTypeFieldMappingForm.php b/src/Form/EventTypeFieldMappingForm.php index a4194ad..f517cfd 100644 --- a/src/Form/EventTypeFieldMappingForm.php +++ b/src/Form/EventTypeFieldMappingForm.php @@ -22,6 +22,7 @@ class EventTypeFieldMappingForm extends EntityForm { EventManagerInterface::FIELD_REGISTRATION_GROUPS, EventManagerInterface::FIELD_STATUS, EventManagerInterface::FIELD_CAPACITY, + EventManagerInterface::FIELD_WAIT_LIST, EventManagerInterface::FIELD_EMAIL_REPLY_TO, EventManagerInterface::FIELD_ALLOW_DUPLICATE_REGISTRANTS, EventManagerInterface::FIELD_REGISTRATION_REGISTRANTS_MINIMUM, diff --git a/src/RegistrationStorage.php b/src/RegistrationStorage.php new file mode 100644 index 0000000..9d08240 --- /dev/null +++ b/src/RegistrationStorage.php @@ -0,0 +1,65 @@ +setDispatcher($container->get('event_dispatcher')); + return $instance; + } + + /** + * Set the event dispatcher. + * + * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher + */ + public function setDispatcher(EventDispatcherInterface $event_dispatcher) { + $this->eventDispatcher = $event_dispatcher; + } + + /** + * {@inheritdoc} + */ + protected function invokeHook($hook, EntityInterface $entity) { + parent::invokeHook($hook, $entity); + $this->eventDispatcher->dispatch($this->getEventName($hook), new RegistrationEvent($entity)); + } + + /** + * Gets the event name for the given hook. + * + * Created using the the entity type's module name and ID. + * For example, the 'presave' hook for registration entities maps + * to the 'rng.registration.presave' event name. + * + * @param string $hook + * One of 'load', 'create', 'presave', 'insert', 'update', 'predelete', + * 'delete', 'translation_insert', 'translation_delete'. + * + * @return string + * The event name. + */ + protected function getEventName($hook) { + return $this->entityType->getProvider() . '.' . $this->entityType->id() . '.' . $hook; + } + +} From 8e009e01cc3c7440c0028ed9e9a95d0b9bf3c8d9 Mon Sep 17 00:00:00 2001 From: Lucas D Hedding Date: Tue, 11 Sep 2018 15:15:12 -0500 Subject: [PATCH 2/5] fix logic error in determining if a waitlist is needed --- src/EventSubscriber/RegistrationWaitlistSubscriber.php | 2 +- src/EventSubscriber/RngRegistrationCreationSubscriber.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EventSubscriber/RegistrationWaitlistSubscriber.php b/src/EventSubscriber/RegistrationWaitlistSubscriber.php index 2cb3502..ebeb829 100644 --- a/src/EventSubscriber/RegistrationWaitlistSubscriber.php +++ b/src/EventSubscriber/RegistrationWaitlistSubscriber.php @@ -61,7 +61,7 @@ public static function getSubscribedEvents() { */ public function onRegistrationInsert(RegistrationEvent $event) { $meta = $this->rngEventManager->getMeta($event->getRegistration()->getEvent()); - if ($meta->allowWaitList() && $meta->remainingCapacity() < 1) { + if ($meta->allowWaitList() && $meta->remainingCapacity() === 0) { $this->messenger->addStatus($this->t('Registration is at its capacity. You have been added to a waiting list.')); } } diff --git a/src/EventSubscriber/RngRegistrationCreationSubscriber.php b/src/EventSubscriber/RngRegistrationCreationSubscriber.php index 48ccb6d..04289df 100644 --- a/src/EventSubscriber/RngRegistrationCreationSubscriber.php +++ b/src/EventSubscriber/RngRegistrationCreationSubscriber.php @@ -89,7 +89,7 @@ public function acceptingRegistration(RegistrationAccessEvent $event) { */ public function remainingCapacity(RegistrationAccessEvent $event) { $meta = $this->getMeta($event->getContext()); - if (!$meta->allowWaitList() && $meta->remainingCapacity() < 1) { + if (!$meta->allowWaitList() && $meta->remainingCapacity() === 0) { $event->setAccess(FALSE); } } From e3f99ac251834cc9e16fcf73fa01ae1361ee85e9 Mon Sep 17 00:00:00 2001 From: Lucas D Hedding Date: Tue, 11 Sep 2018 15:52:27 -0500 Subject: [PATCH 3/5] fix logic error in determining if a waitlist is needed --- src/EventSubscriber/RegistrationWaitlistSubscriber.php | 2 +- src/EventSubscriber/RngRegistrationCreationSubscriber.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EventSubscriber/RegistrationWaitlistSubscriber.php b/src/EventSubscriber/RegistrationWaitlistSubscriber.php index ebeb829..2d3911a 100644 --- a/src/EventSubscriber/RegistrationWaitlistSubscriber.php +++ b/src/EventSubscriber/RegistrationWaitlistSubscriber.php @@ -61,7 +61,7 @@ public static function getSubscribedEvents() { */ public function onRegistrationInsert(RegistrationEvent $event) { $meta = $this->rngEventManager->getMeta($event->getRegistration()->getEvent()); - if ($meta->allowWaitList() && $meta->remainingCapacity() === 0) { + if ($meta->allowWaitList() && ($meta->getCapacity() - $meta->countRegistrations()) < 0) { $this->messenger->addStatus($this->t('Registration is at its capacity. You have been added to a waiting list.')); } } diff --git a/src/EventSubscriber/RngRegistrationCreationSubscriber.php b/src/EventSubscriber/RngRegistrationCreationSubscriber.php index 04289df..48ccb6d 100644 --- a/src/EventSubscriber/RngRegistrationCreationSubscriber.php +++ b/src/EventSubscriber/RngRegistrationCreationSubscriber.php @@ -89,7 +89,7 @@ public function acceptingRegistration(RegistrationAccessEvent $event) { */ public function remainingCapacity(RegistrationAccessEvent $event) { $meta = $this->getMeta($event->getContext()); - if (!$meta->allowWaitList() && $meta->remainingCapacity() === 0) { + if (!$meta->allowWaitList() && $meta->remainingCapacity() < 1) { $event->setAccess(FALSE); } } From 086ded98464937128847e8e5acc4d5a400673938 Mon Sep 17 00:00:00 2001 From: Lucas D Hedding Date: Wed, 12 Sep 2018 09:04:06 -0500 Subject: [PATCH 4/5] add views support for waitlisted events --- rng_views/extra/event.registrations.yml | 76 +++++++++++++++++++++---- rng_views/rng_views.module | 30 ++++++++++ 2 files changed, 96 insertions(+), 10 deletions(-) diff --git a/rng_views/extra/event.registrations.yml b/rng_views/extra/event.registrations.yml index 9c36b6e..cf8bf75 100644 --- a/rng_views/extra/event.registrations.yml +++ b/rng_views/extra/event.registrations.yml @@ -241,7 +241,21 @@ display: entity_type: registration plugin_id: entity_operations filters: { } - sorts: { } + sorts: + id: + id: id + table: registration_field_data + field: id + relationship: none + group_type: group + admin_label: '' + order: ASC + exposed: false + expose: + label: '' + entity_type: registration + entity_field: id + plugin_id: standard title: Registrations header: { } footer: { } @@ -309,15 +323,56 @@ display: display_extenders: { } cache_metadata: contexts: - - 'languages:language_content' - - 'languages:language_interface' - - url - - user + - 'languages:language_content' + - 'languages:language_interface' + - url cacheable: false + max-age: -1 + tags: { } + attachment_1: + display_plugin: attachment + id: attachment_1 + display_title: 'Waitlisted Registrations' + position: 2 + display_options: + display_extenders: + views_advanced_routing_route: + route: '' + display_description: '' + title: 'Waitlisted Registrations' + defaults: + title: false + empty: false + pager: + type: none + options: + offset: 0 + attachment_position: after + displays: + page_1: page_1 + empty: + area_text_custom: + id: area_text_custom + table: views + field: area_text_custom + relationship: none + group_type: group + admin_label: '' + empty: true + tokenize: false + content: 'No waitlisted registrations.' + plugin_id: text_custom + cache_metadata: + max-age: -1 + contexts: + - 'languages:language_content' + - 'languages:language_interface' + - url + tags: { } page_1: display_plugin: page id: page_1 - display_title: 'My Page' + display_title: Registrations position: 1 display_options: display_extenders: @@ -344,8 +399,9 @@ display: display_description: '' cache_metadata: contexts: - - 'languages:language_content' - - 'languages:language_interface' - - url - - user + - 'languages:language_content' + - 'languages:language_interface' + - url cacheable: false + max-age: -1 + tags: { } diff --git a/rng_views/rng_views.module b/rng_views/rng_views.module index eff9e5b..9671f84 100644 --- a/rng_views/rng_views.module +++ b/rng_views/rng_views.module @@ -178,3 +178,33 @@ function rng_views_event_registrations(EntityTypeInterface $entity_type) { return $view; } + +/** + * Implements hook_views_query_alter(). + */ +function rng_views_views_query_alter(ViewExecutable $view, QueryPluginBase $query) { + /** @var \Drupal\rng\EventManager $event_manager */ + $event_manager = \Drupal::service('rng.event_manager'); + $event_types = $event_manager->getEventTypes(); + foreach (array_keys($event_types) as $entity_type) { + if ($view->id() == "rng_registrations_$entity_type") { + /** @var \Drupal\Core\Routing\RouteMatchInterface $route_match */ + $route_match = \Drupal::service('current_route_match'); + /** @var \Drupal\Core\Entity\EntityInterface $event */ + if ($event = $route_match->getParameter($entity_type)) { + if ($meta = $event_manager->getMeta($event)) { + // If we waitlist and have a registration limit, set some defaults. + if ($meta->allowWaitList() && $meta->getRegistrantsMaximum() > 0) { + if ($view->getDisplay()->display['id'] == 'page_1') { + $query->setLimit($meta->getRegistrantsMaximum()); + } + if ($view->getDisplay()->display['id'] == 'attachment_1') { + $view->setOffset($meta->getRegistrantsMaximum()); + } + } + } + } + + } + } +} From 0e0d475c25275a9fc4fef459e5db02ee2bb53808 Mon Sep 17 00:00:00 2001 From: Lucas D Hedding Date: Wed, 12 Sep 2018 09:33:33 -0500 Subject: [PATCH 5/5] add views imports --- rng_views/rng_views.module | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rng_views/rng_views.module b/rng_views/rng_views.module index 9671f84..1df7d66 100644 --- a/rng_views/rng_views.module +++ b/rng_views/rng_views.module @@ -3,7 +3,8 @@ use Drupal\Component\Serialization\Yaml; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\views\Entity\View; -use Drupal\Core\Form\FormStateInterface; +use Drupal\views\Plugin\views\query\QueryPluginBase; +use Drupal\views\ViewExecutable; /** * Implements hook_form_BASE_FORM_ID_alter().