Commit c8c0199d authored by Dimitar Stojanovski's avatar Dimitar Stojanovski Committed by Nejc Koporec
Browse files

Issue #3220070: In module settings, leaving empty to enable entity recycle on...

Issue #3220070: In module settings, leaving empty to enable entity recycle on all bundles doesn't do anything
parent 2cde2646
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -81,8 +81,9 @@ class EntityRecycleDeleteForm extends FormBase {

    // Get entity delete form.
    $form = $this->entityFormBuilder->getForm($entity, 'delete');
    if ($entity->hasField('recycle_bin')) {
      $recycleBinField = $entity->get(EntityRecycleManager::RECYCLE_BIN_FIELD)->value;

    }
    // Alter form titles.
    if ($recycleBinField) {
      $deletePermission = $this->currentUser()
@@ -147,7 +148,7 @@ class EntityRecycleDeleteForm extends FormBase {

    // If already in recycle bin,
    // delete in permanently.
    if ($inRecycleBin) {
    if ($inRecycleBin || !($entity->hasField('recycle_bin'))) {
      $this->moduleHandler->invokeAll('recycle_bin_entity_pre_delete', [&$entity]);
      $entity->delete();
      $this->moduleHandler->invokeAll('recycle_bin_entity_deleted');
+12 −0
Original line number Diff line number Diff line
@@ -203,6 +203,18 @@ class EntityRecycleSettingsForm extends ConfigFormBase {
    $savedTypes = $this->entityRecycleManager->getSetting('types');
    $submittedTypes = $this->getSubmittedTypes($form_state);

    // Select all bundles on which to enable entity recycle bin if nothing is selected.
    foreach ($submittedTypes as $entityType => $bundles) {
      if (empty($submittedTypes[$entityType])) {
        $allBundles = $form_state->getValue('general')[$entityType]['bundles'];
        foreach ($allBundles as $bundle => $value) {
          $value = $bundle;
          $allBundles[$bundle] = $value;
        }
        $submittedTypes[$entityType] = $allBundles;
      }
    }

    // Remove any existing fields.
    foreach ($submittedTypes as $entityTypeId => $bundles) {
      if (!in_array($entityTypeId, $savedTypes) && !is_array($bundles)) {