Commit 09704aef authored by nicola85's avatar nicola85

Avoid error when a referenced bat unit was deleted

parent 0198adc7
......@@ -532,7 +532,9 @@ function bee_entity_view_alter(array &$build, EntityInterface $entity, EntityVie
$units_ids = [];
foreach ($node->get('field_availability_' . $bat_type->bundle()) as $unit) {
$units_ids[] = $unit->entity->id();
if ($unit->entity) {
$units_ids[] = $unit->entity->id();
}
}
if ($bat_type->bundle() == 'daily') {
......
......@@ -26,7 +26,9 @@ class BeeController extends ControllerBase implements ContainerInjectionInterfac
$bat_unit_ids = [];
foreach ($node->get('field_availability_' . $bee_settings['bookable_type']) as $unit) {
$bat_unit_ids[] = $unit->entity->id();
if ($unit->entity) {
$bat_unit_ids[] = $unit->entity->id();
}
}
if ($bee_settings['bookable_type'] == 'daily') {
......
......@@ -91,7 +91,9 @@ class OrderEventSubscriber implements EventSubscriberInterface {
$units_ids = [];
foreach ($node->get('field_availability_' . $bee_settings['bookable_type']) as $unit) {
$units_ids[] = $unit->entity->id();
if ($unit->entity) {
$units_ids[] = $unit->entity->id();
}
}
$temp_end_date = clone($end_date);
......
......@@ -272,7 +272,9 @@ class AddReservationForm extends FormBase {
$units_ids = [];
foreach ($node->get('field_availability_' . $bee_settings['bookable_type']) as $unit) {
$units_ids[] = $unit->entity->id();
if ($unit->entity) {
$units_ids[] = $unit->entity->id();
}
}
if ($bee_settings['bookable_type'] == 'daily') {
......
......@@ -238,7 +238,9 @@ class UpdateAvailabilityForm extends FormBase {
$units_ids = [];
foreach ($node->get('field_availability_hourly') as $unit) {
$units_ids[] = $unit->entity->id();
if ($unit->entity) {
$units_ids[] = $unit->entity->id();
}
}
$units = array_intersect($units_ids, $available_units);
......@@ -292,7 +294,9 @@ class UpdateAvailabilityForm extends FormBase {
$units_ids = [];
foreach ($node->get('field_availability_hourly') as $unit) {
$units_ids[] = $unit->entity->id();
if ($unit->entity) {
$units_ids[] = $unit->entity->id();
}
}
$units = array_intersect($units_ids, $available_units);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment