From 79e111156101c10369f9d68c63c9f57076ca02da Mon Sep 17 00:00:00 2001 From: ppound Date: Thu, 15 Jul 2021 14:33:53 -0300 Subject: [PATCH] code formatting and eliminate a log notice --- reserve.inc | 32 +++++++++++++------------------- reserve.series.inc | 10 ++++------ 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/reserve.inc b/reserve.inc index ee93102..9224708 100644 --- a/reserve.inc +++ b/reserve.inc @@ -25,13 +25,9 @@ function reserve_categories($ebundle = null) { $ids = array_filter($fconfig['categories']); } else { - $query = \Drupal::service('entity_type.manager')->getStorage('reserve_category')->getQuery(); + $query = \Drupal::service('entity_type.manager') + ->getStorage('reserve_category')->getQuery(); $ids = $query->condition('status', TRUE)->execute(); - //$ids = Drupal::service('entity.query') - //->get('reserve_category') - //->condition('status', TRUE) - //->sort('reserve_display_order', 'ASC') - //->execute(); } $cats = \Drupal::entityTypeManager()->getStorage('reserve_category')->loadMultiple($ids); @@ -61,11 +57,9 @@ function reserve_categories($ebundle = null) { function reserve_entities($ebundle) { $entity_type = ebundle_split($ebundle, 'type'); $bundle = ebundle_split($ebundle, 'bundle'); - $query = \Drupal::service('entity_type.manager')->getStorage($entity_type)->getQuery(); + $query = \Drupal::service('entity_type.manager') + ->getStorage($entity_type)->getQuery(); $query->condition('status', TRUE); - //$query = Drupal::service('entity.query') - // ->get($entity_type) - // ->condition('status', TRUE); if ($entity_type != $bundle) { $query->condition('type', $bundle); @@ -809,8 +803,8 @@ function reserve_valid_lengths($rid, $ebundle, $yyyy_mmdd, $time, $id = NULL, $a $start_time = $search_item['start_time']; $conflicts_found = false; - $query = \Drupal::service('entity_type.manager')->getStorage('reserve_reservation')->getQuery() - //$query = Drupal::service('entity.query') + $query = \Drupal::service('entity_type.manager') + ->getStorage('reserve_reservation')->getQuery() ->condition('reservation_date', $date . '%', 'LIKE') ->condition('reservation_time', $start_time) ->condition('reservable_id', $rid) @@ -939,8 +933,8 @@ function reserve_daily_max_exceeded($yyyy_mmdd) { $record_count = 0; if ($user->uid) { - $ids = \Drupal::service('entity_type.manager')->getStorage('reserve_reservation')->getQuery() - //$ids = \Drupal::service('entity.query') + $ids = \Drupal::service('entity_type.manager') + ->getStorage('reserve_reservation')->getQuery() ->condition('user_id', $user->id) ->condition('reservation_date', 'value', $yyyy_mmdd . '%', 'like') ->execute(); @@ -973,9 +967,8 @@ function reserve_user_reservations() { if ($user->id()) { $earliest_date = date('Y-m-d', strtotime(date('Y-m-d'))); $latest_date = date('Y-m-d', strtotime("now +13 days")); - $ids = \Drupal::service('entity_type.manager')->getStorage('reserve_reservation')->getQuery() - //$ids = \Drupal::service('entity.query') - // ->get('reserve_reservation') + $ids = \Drupal::service('entity_type.manager') + ->getStorage('reserve_reservation')->getQuery() ->condition('user_id', $user->id()) ->condition('reservation_date', $earliest_date, '>=') ->condition('reservation_date', $latest_date, '<=') @@ -1074,8 +1067,9 @@ function reserve_category_fields($ebundle = NULL) { function ebundle_split($ebundle, $part) { $ebits = explode('.', $ebundle); - if ($part == 'type') return $ebits[0]; - if ($part == 'bundle') return $ebits[1]; + if ($part == 'type' && isset($ebits[0])) return $ebits[0]; + if ($part == 'bundle' && isset($ebits[1])) return $ebits[1]; + return NULL; } /* diff --git a/reserve.series.inc b/reserve.series.inc index 488f653..eb2681d 100644 --- a/reserve.series.inc +++ b/reserve.series.inc @@ -128,9 +128,8 @@ function reserve_reserve_reservation_update($entity) { $private = $entity->reservation_private->getString(); // grab all reservations in this series except the one being submitted - $ids = \Drupal::service('entity_type.manager')->getStorage('reserve_reservation')->getQuery() - //$ids = \Drupal::service('entity.query') - // ->get('reserve_reservation') + $ids = \Drupal::service('entity_type.manager') + ->getStorage('reserve_reservation')->getQuery() ->condition('status', TRUE) ->condition('reservation_series_id', $sid) ->condition('id', $entity->id(), '!=') @@ -182,9 +181,8 @@ function reserve_reserve_reservation_delete($entity) { function _reserve_series_delete($entity) { $sid = $entity->get('reservation_series_id')->getString(); // grab all reservations in this series - $ids = \Drupal::service('entity_type.manager')->getStorage('reserve_reservation')->getQuery() - //$ids = \Drupal::service('entity.query') - // ->get('reserve_reservation') + $ids = \Drupal::service('entity_type.manager') + ->getStorage('reserve_reservation')->getQuery() ->condition('reservation_series_id', $sid) ->execute(); $results = \Drupal::entityTypeManager()->getStorage('reserve_reservation')->loadMultiple($ids);