UnflaggingForm.php in Flag 8.4
File
src/Form/UnflaggingForm.php
View source
<?php
namespace Drupal\flag\Form;
use Drupal\Core\Form\FormStateInterface;
use Drupal\flag\Plugin\ActionLink\FormEntryInterface;
class UnflaggingForm extends FlagConfirmFormBase {
protected $flagging;
protected $entity;
protected $flag;
public function getFormId() {
return 'unflagging_form';
}
public function getQuestion() {
$link_plugin = $this->flag
->getLinkTypePlugin();
return $link_plugin instanceof FormEntryInterface ? $link_plugin
->getUnflagQuestion() : $this
->t('Unflag this content');
}
public function getDescription() {
return $this->flag
->getLongText('unflag');
}
public function getConfirmText() {
$link_plugin = $this->flag
->getLinkTypePlugin();
return $link_plugin instanceof FormEntryInterface ? $link_plugin
->getDeleteButtonText() : $this
->t('Unflag');
}
public function submitForm(array &$form, FormStateInterface $form_state) {
\Drupal::service('flag')
->unflag($this->flag, $this->entity);
}
}