From 42217163520fd09baeb3669cb96e94695e5537d7 Mon Sep 17 00:00:00 2001 From: John Voskuilen <john.voskuilen@sapito.nl> Date: Wed, 15 Jan 2025 16:54:20 +0100 Subject: [PATCH] Issue #3499896: Error: Call to undefined function --> move views.inc file into .module file --- office_hours.module | 46 ++++++++++++++++++++++++++++++++++-- office_hours.views.inc | 53 ------------------------------------------ 2 files changed, 44 insertions(+), 55 deletions(-) delete mode 100644 office_hours.views.inc diff --git a/office_hours.module b/office_hours.module index 649f63fb..fbff006c 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 fa382883..00000000 --- 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); -} -- GitLab