FlagConfirmFormBase.php in Flag 8.4        
                          
                  
                        
  
  
  
  
  
File
  src/Form/FlagConfirmFormBase.php
  
    View source  
  <?php
namespace Drupal\flag\Form;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\flag\FlagInterface;
abstract class FlagConfirmFormBase extends ConfirmFormBase {
  
  protected $entity;
  
  protected $flag;
  
  public function buildForm(array $form, FormStateInterface $form_state, FlagInterface $flag = NULL, $entity_id = NULL) {
    $this->flag = $flag;
    $flag_service = \Drupal::service('flag');
    $this->entity = $flag_service
      ->getFlaggableById($this->flag, $entity_id);
    return parent::buildForm($form, $form_state);
  }
  
  public function getCancelUrl() {
    return $this->entity
      ->toUrl();
  }
  
  public function getFlag() {
    return $this->flag;
  }
}