Commit 14ee3aa3 authored by Jonathan Sacksick's avatar Jonathan Sacksick
Browse files

Issue #3262858 by jsacksick: Promotion enabled/disabled operations were reverted by mistake.

parent 33aa9d8c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ class PromotionDisableForm extends ContentEntityConfirmFormBase {
    $promotion = $this->getEntity();
    $promotion->setEnabled(FALSE);
    $promotion->save();
    $this->messenger()->addStatus($this->t('Successfully disabled the promotion %label', ['%label' => $promotion->label()]));
    $this->messenger()->addStatus($this->t('Successfully disabled the promotion %label.', ['%label' => $promotion->label()]));
    $form_state->setRedirectUrl($this->getCancelUrl());
  }

+1 −1
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ class PromotionEnableForm extends ContentEntityConfirmFormBase {
    $promotion = $this->getEntity();
    $promotion->setEnabled(TRUE);
    $promotion->save();
    $this->messenger()->addStatus($this->t('Successfully enabled the promotion %label', ['%label' => $promotion->label()]));
    $this->messenger()->addStatus($this->t('Successfully enabled the promotion %label.', ['%label' => $promotion->label()]));
    $form_state->setRedirectUrl($this->getCancelUrl());
  }

+15 −0
Original line number Diff line number Diff line
@@ -269,6 +269,21 @@ class PromotionListBuilder extends EntityListBuilder implements FormInterface {
          'commerce_promotion' => $entity->id(),
        ]),
      ];

      if (!$entity->isEnabled() && $entity->hasLinkTemplate('enable-form')) {
        $operations['enable'] = [
          'title' => $this->t('Enable'),
          'weight' => -10,
          'url' => $this->ensureDestination($entity->toUrl('enable-form')),
        ];
      }
      elseif ($entity->hasLinkTemplate('disable-form')) {
        $operations['disable'] = [
          'title' => $this->t('Disable'),
          'weight' => 40,
          'url' => $this->ensureDestination($entity->toUrl('disable-form')),
        ];
      }
    }

    return $operations;