class QuizAddQuestionAction in Quiz 8.5
Same name and namespace in other branches
- 8.6 src/Plugin/Action/QuizAddQuestionAction.php \Drupal\quiz\Plugin\Action\QuizAddQuestionAction
- 6.x src/Plugin/Action/QuizAddQuestionAction.php \Drupal\quiz\Plugin\Action\QuizAddQuestionAction
Action description.
Plugin annotation
@Action(
id = "quiz_add_question_to_quiz",
label = @Translation("Add questions to quiz"),
type = "quiz_question"
)
Hierarchy
- class \Drupal\quiz\Plugin\Action\QuizAddQuestionAction extends \Drupal\views_bulk_operations\Action\ViewsBulkOperationsActionBase uses StringTranslationTrait
Expanded class hierarchy of QuizAddQuestionAction
File
- src/
Plugin/ Action/ QuizAddQuestionAction.php, line 19
Namespace
Drupal\quiz\Plugin\ActionView source
class QuizAddQuestionAction extends ViewsBulkOperationsActionBase {
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
public function execute($entity = NULL) {
/* @var $url Drupal\Core\Url */
$url = $this->context['redirect_url'];
$qid = $url
->getRouteParameters()['quiz'];
$quiz = \Drupal::entityTypeManager()
->getStorage('quiz')
->loadRevision($qid);
$quiz
->addQuestion($entity);
return $this
->t('Added question to quiz.');
}
/**
* {@inheritdoc}
*/
public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
return TRUE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
QuizAddQuestionAction:: |
public | function | ||
QuizAddQuestionAction:: |
public | function | ||
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |