You are here

public function Instances::revertAjax in Smart Date 3.4.x

Same name and namespace in other branches
  1. 8.2 modules/smart_date_recur/src/Controller/Instances.php \Drupal\smart_date_recur\Controller\Instances::revertAjax()
  2. 3.x modules/smart_date_recur/src/Controller/Instances.php \Drupal\smart_date_recur\Controller\Instances::revertAjax()
  3. 3.0.x modules/smart_date_recur/src/Controller/Instances.php \Drupal\smart_date_recur\Controller\Instances::revertAjax()
  4. 3.1.x modules/smart_date_recur/src/Controller/Instances.php \Drupal\smart_date_recur\Controller\Instances::revertAjax()
  5. 3.2.x modules/smart_date_recur/src/Controller/Instances.php \Drupal\smart_date_recur\Controller\Instances::revertAjax()
  6. 3.3.x modules/smart_date_recur/src/Controller/Instances.php \Drupal\smart_date_recur\Controller\Instances::revertAjax()

Reverting a rule instance in an Ajax confirm dialog.

Parameters

\Drupal\smart_date_recur\Entity\SmartDateOverride $entity: The override entity to remove.

bool $confirm: Whether or not the removal has been confirmed.

Return value

\Drupal\Core\Ajax\AjaxResponse The AJAX response object.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

1 string reference to 'Instances::revertAjax'
smart_date_recur.routing.yml in modules/smart_date_recur/smart_date_recur.routing.yml
modules/smart_date_recur/smart_date_recur.routing.yml

File

modules/smart_date_recur/src/Controller/Instances.php, line 479

Class

Instances
Provides listings of instances (with overrides) for a specified rule.

Namespace

Drupal\smart_date_recur\Controller

Code

public function revertAjax(SmartDateOverride $entity, bool $confirm) {
  if ($confirm) {
    $rrule = $this
      ->entityTypeManager()
      ->getStorage('smart_date_rule')
      ->load($entity->rrule->value);
    $this
      ->setSmartDateRule($rrule);
    $this
      ->setUseAjax(TRUE);
    $this
      ->revertInstance($entity);
    $content = $this
      ->listInstancesOutput();
  }
  else {
    $content = \Drupal::formBuilder()
      ->getForm(SmartDateOverrideDeleteAjaxForm::class, $entity);
  }
  $form['#attached']['library'][] = 'core/drupal.ajax';
  $response = new AjaxResponse();
  $response
    ->addCommand(new ReplaceCommand('#manage-instances', $content));
  return $response;
}