BookingBundleDeleteConfirm.php in Booking and Availability Management Tools for Drupal 8
File
modules/bat_booking/src/Form/BookingBundleDeleteConfirm.php
View source
<?php
namespace Drupal\bat_booking\Form;
use Drupal\Core\Entity\EntityDeleteForm;
use Drupal\Core\Form\FormStateInterface;
class BookingBundleDeleteConfirm extends EntityDeleteForm {
public function buildForm(array $form, FormStateInterface $form_state) {
$form = parent::buildForm($form, $form_state);
$entity = $this
->getEntity();
$type_bundle = $entity
->id();
if (count(bat_booking_load_multiple([], [
'type' => $type_bundle,
]))) {
$this
->messenger()
->addError(t('This Bat Booking bundle has associated Types. Please delete all Types before attempting to delete this Bat Booking bundle.'));
return [];
}
return $form;
}
}