title: EasyAdminBundle: how to redirect back to form
body: <p>In the admin panel created with EasyAdminBundle, the administrator can create a new Booking. I want to add an availability check (via a service) before this new booking instance is persisted into the database. If this check returns false, the admin should be redirected back to the form.</p>
  
  <p>I have extended the <code>EasyCorp\Bundle\EasyAdminBundle\Controller\AdminController</code> class and overridden the <code>persistEntity()</code> function:</p>
  
  <pre><code>...
  use EasyCorp\Bundle\EasyAdminBundle\Controller\AdminController as BaseAdminController;
  
  class BookingController extends BaseAdminController
  {
      private $availabilityService;
  
      public function __construct(AvailabilityService $availabilityService)
      {
          $this-&gt;availabilityService = $availabilityService;
      }
  
      protected function persistEntity($booking)
      {
          $checkin = Carbon::instance($booking-&gt;getCheckin());
          $checkout = Carbon::instance($booking-&gt;getCheckout());
  
          if($this-&gt;availabilityService-&gt;checkAvailability($checkin, $checkout)) {
              parent::persistEntity($booking);
          } else {
              return false; //redirect back to the form
          }
      }
  }
  </code></pre>