Browse Source

code formatting and eliminate a log notice

d9
ppound 4 years ago
parent
commit
79e1111561
  1. 32
      reserve.inc
  2. 10
      reserve.series.inc

32
reserve.inc

@ -25,13 +25,9 @@ function reserve_categories($ebundle = null) {
$ids = array_filter($fconfig['categories']); $ids = array_filter($fconfig['categories']);
} }
else { 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 = $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); $cats = \Drupal::entityTypeManager()->getStorage('reserve_category')->loadMultiple($ids);
@ -61,11 +57,9 @@ function reserve_categories($ebundle = null) {
function reserve_entities($ebundle) { function reserve_entities($ebundle) {
$entity_type = ebundle_split($ebundle, 'type'); $entity_type = ebundle_split($ebundle, 'type');
$bundle = ebundle_split($ebundle, 'bundle'); $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->condition('status', TRUE);
//$query = Drupal::service('entity.query')
// ->get($entity_type)
// ->condition('status', TRUE);
if ($entity_type != $bundle) { if ($entity_type != $bundle) {
$query->condition('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']; $start_time = $search_item['start_time'];
$conflicts_found = false; $conflicts_found = false;
$query = \Drupal::service('entity_type.manager')->getStorage('reserve_reservation')->getQuery() $query = \Drupal::service('entity_type.manager')
//$query = Drupal::service('entity.query') ->getStorage('reserve_reservation')->getQuery()
->condition('reservation_date', $date . '%', 'LIKE') ->condition('reservation_date', $date . '%', 'LIKE')
->condition('reservation_time', $start_time) ->condition('reservation_time', $start_time)
->condition('reservable_id', $rid) ->condition('reservable_id', $rid)
@ -939,8 +933,8 @@ function reserve_daily_max_exceeded($yyyy_mmdd) {
$record_count = 0; $record_count = 0;
if ($user->uid) { if ($user->uid) {
$ids = \Drupal::service('entity_type.manager')->getStorage('reserve_reservation')->getQuery() $ids = \Drupal::service('entity_type.manager')
//$ids = \Drupal::service('entity.query') ->getStorage('reserve_reservation')->getQuery()
->condition('user_id', $user->id) ->condition('user_id', $user->id)
->condition('reservation_date', 'value', $yyyy_mmdd . '%', 'like') ->condition('reservation_date', 'value', $yyyy_mmdd . '%', 'like')
->execute(); ->execute();
@ -973,9 +967,8 @@ function reserve_user_reservations() {
if ($user->id()) { if ($user->id()) {
$earliest_date = date('Y-m-d', strtotime(date('Y-m-d'))); $earliest_date = date('Y-m-d', strtotime(date('Y-m-d')));
$latest_date = date('Y-m-d', strtotime("now +13 days")); $latest_date = date('Y-m-d', strtotime("now +13 days"));
$ids = \Drupal::service('entity_type.manager')->getStorage('reserve_reservation')->getQuery() $ids = \Drupal::service('entity_type.manager')
//$ids = \Drupal::service('entity.query') ->getStorage('reserve_reservation')->getQuery()
// ->get('reserve_reservation')
->condition('user_id', $user->id()) ->condition('user_id', $user->id())
->condition('reservation_date', $earliest_date, '>=') ->condition('reservation_date', $earliest_date, '>=')
->condition('reservation_date', $latest_date, '<=') ->condition('reservation_date', $latest_date, '<=')
@ -1074,8 +1067,9 @@ function reserve_category_fields($ebundle = NULL) {
function ebundle_split($ebundle, $part) { function ebundle_split($ebundle, $part) {
$ebits = explode('.', $ebundle); $ebits = explode('.', $ebundle);
if ($part == 'type') return $ebits[0]; if ($part == 'type' && isset($ebits[0])) return $ebits[0];
if ($part == 'bundle') return $ebits[1]; if ($part == 'bundle' && isset($ebits[1])) return $ebits[1];
return NULL;
} }
/* /*

10
reserve.series.inc

@ -128,9 +128,8 @@ function reserve_reserve_reservation_update($entity) {
$private = $entity->reservation_private->getString(); $private = $entity->reservation_private->getString();
// grab all reservations in this series except the one being submitted // 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_type.manager')
//$ids = \Drupal::service('entity.query') ->getStorage('reserve_reservation')->getQuery()
// ->get('reserve_reservation')
->condition('status', TRUE) ->condition('status', TRUE)
->condition('reservation_series_id', $sid) ->condition('reservation_series_id', $sid)
->condition('id', $entity->id(), '!=') ->condition('id', $entity->id(), '!=')
@ -182,9 +181,8 @@ function reserve_reserve_reservation_delete($entity) {
function _reserve_series_delete($entity) { function _reserve_series_delete($entity) {
$sid = $entity->get('reservation_series_id')->getString(); $sid = $entity->get('reservation_series_id')->getString();
// grab all reservations in this series // grab all reservations in this series
$ids = \Drupal::service('entity_type.manager')->getStorage('reserve_reservation')->getQuery() $ids = \Drupal::service('entity_type.manager')
//$ids = \Drupal::service('entity.query') ->getStorage('reserve_reservation')->getQuery()
// ->get('reserve_reservation')
->condition('reservation_series_id', $sid) ->condition('reservation_series_id', $sid)
->execute(); ->execute();
$results = \Drupal::entityTypeManager()->getStorage('reserve_reservation')->loadMultiple($ids); $results = \Drupal::entityTypeManager()->getStorage('reserve_reservation')->loadMultiple($ids);

Loading…
Cancel
Save