@ -25,11 +25,9 @@ function reserve_categories($ebundle = null) {
$ids = array_filter($fconfig['categories']);
}
else {
$ids = Drupal::service('entity.query')
->get('reserve_category')
->condition('status', TRUE)
//->sort('reserve_display_order', 'ASC')
->execute();
$query = \Drupal::service('entity_type.manager')
->getStorage('reserve_category')->getQuery();
$ids = $query->condition('status', TRUE)->execute();
}
$cats = \Drupal::entityTypeManager()->getStorage('reserve_category')->loadMultiple($ids);
@ -59,9 +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.query ')
->get($entity_type)
->condition('status', TRUE);
$query = \Drupal::service('entity_type.manager ')
->getStorage ($entity_type)->getQuery();
$query ->condition('status', TRUE);
if ($entity_type != $bundle) {
$query->condition('type', $bundle);
@ -805,9 +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.query')
->get('reserve_reservation')
$query = \Drupal::service('entity_type.manager')
->getStorage('reserve_reservation')->getQuery()
->condition('reservation_date', $date . '%', 'LIKE')
->condition('reservation_time', $start_time)
->condition('reservable_id', $rid)
@ -926,24 +923,21 @@ function reserve_valid_lengths($rid, $ebundle, $yyyy_mmdd, $time, $id = NULL, $a
* FALSE - the maximum has not been exceeded.
*/
function reserve_daily_max_exceeded($yyyy_mmdd) {
global $user;
$user = \Drupal::currentUser();
$config = \Drupal::config('reserve.settings');
$max = $config->get('reservations_per_day');
if (!$max) {
return FALSE;
}
$record_count = 0;
if ($user->u id) {
$ids = \Drupal::service('entity.query ')
->get('reserve_reservation')
->condition('user_id', $user->id)
->condition('reservation_date', 'value', $yyyy_mmdd . '%', 'like')
if ($user->id() ) {
$ids = \Drupal::service('entity_type.manager ')
->getStorage ('reserve_reservation')->getQuery( )
->condition('user_id', $user->id() )
->condition('reservation_date', $yyyy_mmdd . '%', 'like')
->execute();
$record_count = count($ids);
}
if ($record_count < $max) {
return FALSE;
}
@ -970,9 +964,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.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, '< =')
@ -1032,7 +1025,7 @@ function reserve_yyyymmdd($month, $day) {
*/
function reserve_get_reserve_bundles() {
$bundles = array();
$fieldmap = \Drupal::entityManager( )->getFieldMap();
$fieldmap = \Drupal::service('entity_field.manager' )->getFieldMap();
foreach ($fieldmap as $entity_type => $typedef) {
foreach ($typedef as $field) {
if ($field['type'] == 'reserve_category') {
@ -1050,7 +1043,7 @@ function reserve_get_reserve_bundles() {
* OR specific field name if $ebundle is provided (e.g. node.room)
*/
function reserve_category_fields($ebundle = NULL) {
$fieldmap = \Drupal::entityManager( )->getFieldMap();
$fieldmap = \Drupal::service('entity_field.manager' )->getFieldMap();
$fields = [];
foreach ($fieldmap as $entity_type => $typedef) {
foreach ($typedef as $name => $field) {
@ -1071,8 +1064,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;
}
/*
@ -1112,7 +1106,7 @@ function reserve_which_year($month, $day) {
* used for Allowed Values for Reservation.reservable_content_type field
*/
function reserve_site_entity_types() {
$types = \Drupal::entityManager( )->getEntityTypeLabels(TRUE);
$types = \Drupal::service('entity_type.repository' )->getEntityTypeLabels(TRUE);
return $types['Content'];
}