diff --git a/office_hours.module b/office_hours.module index 649f63fbd075d7d9ade8a7c8adc59387cceebb78..fbff006cd413f374465d9b3cbf64d9845f87c4e2 100644 --- a/office_hours.module +++ b/office_hours.module @@ -7,7 +7,12 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; +use Drupal\field\FieldStorageConfigInterface; use Drupal\office_hours\Plugin\Field\FieldType\OfficeHoursItemBase; +use Drupal\office_hours\Plugin\views\field\FieldBase; +use Drupal\office_hours\Plugin\views\filter\OfficeHoursStatusFilter; +use Drupal\views\Plugin\views\cache\CachePluginBase; +use Drupal\views\ViewExecutable; // Include file, avoiding container error during upgrade. if (\Drupal::hasContainer()) { @@ -15,8 +20,6 @@ if (\Drupal::hasContainer()) { \Drupal::moduleHandler()->loadInclude('office_hours', 'inc', 'office_hours.theme'); // Add ExceptionItem field formatter theming/preprocessing. \Drupal::moduleHandler()->loadInclude('office_hours', 'inc', 'office_hours.theme.exceptions'); - // Add views hooks. - \Drupal::moduleHandler()->loadInclude('office_hours', 'inc', 'office_hours.views'); } /** @@ -68,6 +71,45 @@ function office_hours_form_field_storage_config_edit_form_alter(&$form, FormStat } } +/** + * Implements hook_field_views_data(). + */ +function office_hours_field_views_data(FieldStorageConfigInterface $field_storage) { + $data = views_field_default_views_data($field_storage); + $data = OfficeHoursStatusFilter::viewsFieldData($field_storage, $data); + $data = FieldBase::viewsFieldData($field_storage, $data); + + return $data; +} + +/** + * Implements hook_views_query_substitutions(). + */ +function office_hours_views_query_substitutions(ViewExecutable $view) { + return OfficeHoursStatusFilter::viewsQuerySubstitutions($view); +} + +/** + * Implements hook_views_post_execute(). + */ +function office_hours_views_post_execute(ViewExecutable $view) { + return OfficeHoursStatusFilter::viewsPostExecute($view); +} + +/** + * Implements hook_views_pre_render(). + */ +function office_hours_views_pre_render(ViewExecutable $view) { + return OfficeHoursStatusFilter::viewsPreRender($view); +} + +/** + * Implements hook_views_post_render(). + */ +function office_hours_views_post_render(ViewExecutable $view, array &$output, CachePluginBase $cache) { + return OfficeHoursStatusFilter::viewsPostRender($view, $output, $cache); +} + /** * Implements hook_office_hours_time_format_alter(). */ diff --git a/office_hours.views.inc b/office_hours.views.inc deleted file mode 100644 index fa382883654556b1722d0bb8726eb61e0d8be6d5..0000000000000000000000000000000000000000 --- a/office_hours.views.inc +++ /dev/null @@ -1,53 +0,0 @@ -<?php - -/** - * @file - * Provides views data for the office_hours module. - * - * @ingroup views_module_handlers - */ - -use Drupal\field\FieldStorageConfigInterface; -use Drupal\office_hours\Plugin\views\field\FieldBase; -use Drupal\office_hours\Plugin\views\filter\OfficeHoursStatusFilter; -use Drupal\views\Plugin\views\cache\CachePluginBase; -use Drupal\views\ViewExecutable; - -/** - * Implements hook_field_views_data(). - */ -function office_hours_field_views_data(FieldStorageConfigInterface $field_storage) { - $data = views_field_default_views_data($field_storage); - $data = OfficeHoursStatusFilter::viewsFieldData($field_storage, $data); - $data = FieldBase::viewsFieldData($field_storage, $data); - - return $data; -} - -/** - * Implements hook_views_query_substitutions(). - */ -function office_hours_views_query_substitutions(ViewExecutable $view) { - return OfficeHoursStatusFilter::viewsQuerySubstitutions($view); -} - -/** - * Implements hook_views_post_execute(). - */ -function office_hours_views_post_execute(ViewExecutable $view) { - return OfficeHoursStatusFilter::viewsPostExecute($view); -} - -/** - * Implements hook_views_pre_render(). - */ -function office_hours_views_pre_render(ViewExecutable $view) { - return OfficeHoursStatusFilter::viewsPreRender($view); -} - -/** - * Implements hook_views_post_render(). - */ -function office_hours_views_post_render(ViewExecutable $view, array &$output, CachePluginBase $cache) { - return OfficeHoursStatusFilter::viewsPostRender($view, $output, $cache); -}