Loading feeds.links.action.yml +1 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ feeds.unlock_action: title: Unlock appears_on: - entity.feeds_feed.canonical - feeds.item_list cache_tags: - feeds_feed_locked Loading src/Entity/Feed.php +2 −1 Original line number Diff line number Diff line Loading @@ -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", * } * ) */ Loading src/FeedForm.php +25 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; } } src/FeedListBuilder.php +9 −1 Original line number Diff line number Diff line Loading @@ -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 []; } Loading Loading @@ -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) { Loading Loading
feeds.links.action.yml +1 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ feeds.unlock_action: title: Unlock appears_on: - entity.feeds_feed.canonical - feeds.item_list cache_tags: - feeds_feed_locked Loading
src/Entity/Feed.php +2 −1 Original line number Diff line number Diff line Loading @@ -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", * } * ) */ Loading
src/FeedForm.php +25 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; } }
src/FeedListBuilder.php +9 −1 Original line number Diff line number Diff line Loading @@ -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 []; } Loading Loading @@ -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) { Loading