Commit d891643a authored by Govind Malu's avatar Govind Malu Committed by Youri van Koppen
Browse files

Issue #3166456 by govind.maloo, lolcode, ramil g: Added "Unlock" to the...

Issue #3166456 by govind.maloo, lolcode, ramil g: Added "Unlock" to the operations menu on the main Feeds page.
parent e6726151
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ feeds.unlock_action:
  title: Unlock
  appears_on:
    - entity.feeds_feed.canonical
    - feeds.item_list
  cache_tags:
    - feeds_feed_locked

+2 −1
Original line number Diff line number Diff line
@@ -74,7 +74,8 @@ use Drupal\user\UserInterface;
 *     "edit-form" = "/feed/{feeds_feed}/edit",
 *     "import-form" = "/feed/{feeds_feed}/import",
 *     "schedule-import-form" = "/feed/{feeds_feed}/schedule-import",
 *     "clear-form" = "/feed/{feeds_feed}/delete-items"
 *     "clear-form" = "/feed/{feeds_feed}/delete-items",
 *     "unlock" = "/feed/{feeds_feed}/unlock",
 *   }
 * )
 */
+25 −0
Original line number Diff line number Diff line
@@ -120,6 +120,17 @@ class FeedForm extends ContentEntityForm {
      $element['import']['#submit'][] = '::import';
    }

    // Add an "unlock" button.
    if ($this->entity->access('unlock')) {
      $element['submit']['#dropbutton'] = 'save';
      $element['submit']['#weight'] = 1;
      $element['unlock'] = $element['submit'];
      $element['unlock']['#dropbutton'] = 'save';
      $element['unlock']['#value'] = $this->t('Unlock and Save');
      $element['unlock']['#weight'] = 0;
      $element['unlock']['#submit'][] = '::unlock';
    }

    $element['delete']['#access'] = $this->entity->access('delete');

    return $element;
@@ -257,4 +268,18 @@ class FeedForm extends ContentEntityForm {
    return $this->formFactory->hasForm($plugin, $operation);
  }

  /**
   * Form submission handler for the 'unlock' action.
   *
   * @param array $form
   *   An associative array containing the structure of the form.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The current state of the form.
   */
  public function unlock(array $form, FormStateInterface $form_state) {
    $feed = $this->entity;
    $feed->unlock();
    return $feed;
  }

}
+9 −1
Original line number Diff line number Diff line
@@ -91,7 +91,7 @@ class FeedListBuilder extends EntityListBuilder {
   * {@inheritdoc}
   */
  public function buildRow(EntityInterface $entity) {
    if (!$entity->access('view') && !$entity->access('update') && !$entity->access('import') && !$entity->access('schedule_import') && !$entity->access('clear')) {
    if (!$entity->access('view') && !$entity->access('update') && !$entity->access('import') && !$entity->access('schedule_import') && !$entity->access('clear') && !$entity->access('unlock')) {
      return [];
    }

@@ -158,6 +158,14 @@ class FeedListBuilder extends EntityListBuilder {
      ];
    }

    if ($entity->access('unlock') && $entity->hasLinkTemplate('unlock')) {
      $operations['unlock'] = [
        'title' => $this->t('Unlock'),
        'weight' => 5,
        'url' => $entity->toUrl('unlock'),
      ];
    }

    $destination = $this->redirectDestination->getAsArray();

    foreach ($operations as $key => $operation) {