recurring_events-2.0.x-dev/modules/recurring_events_registration/src/Plugin/views/field/EventInstanceWaitlistCount.php

modules/recurring_events_registration/src/Plugin/views/field/EventInstanceWaitlistCount.php
<?php

declare(strict_types=1);

namespace Drupal\recurring_events_registration\Plugin\views\field;

use Drupal\views\Attribute\ViewsField;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;

/**
 * Field handler to show the count of waitlisted registrants.
 *
 * @ingroup views_field_handlers
 */
#[ViewsField(
  id: "eventinstance_waitlist_count",
)]
class EventInstanceWaitlistCount extends FieldPluginBase {

  /**
   * {@inheritdoc}
   */
  public function query() {
    // Leave empty to avoid a query on this field.
  }

  /**
   * {@inheritdoc}
   */
  public function render(ResultRow $values) {
    $event = $values->_entity;
    return $event->get('waitlist_count')->getValue()[0]['value'] ?? 0;
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc