You are here

public function QuizFeedbackType::getComponent in Quiz 8.6

Same name and namespace in other branches
  1. 8.5 src/Entity/QuizFeedbackType.php \Drupal\quiz\Entity\QuizFeedbackType::getComponent()
  2. 6.x src/Entity/QuizFeedbackType.php \Drupal\quiz\Entity\QuizFeedbackType::getComponent()

Gets the Rules component to be edited.

Return value

\Drupal\rules\Engine\RulesComponent The Rules component.

Overrides RulesUiComponentProviderInterface::getComponent

File

src/Entity/QuizFeedbackType.php, line 57

Class

QuizFeedbackType
Defines the quiz type entity class.

Namespace

Drupal\quiz\Entity

Code

public function getComponent() {
  if (empty($this->component)) {

    // Provide a default for now.
    // @todo make expression configurable.
    $this->component = [
      'expression' => [
        'id' => 'rules_and',
      ],
      'context_definitions' => [
        'quiz_result' => [
          'type' => 'entity:quiz_result',
          'label' => 'Quiz result',
          'description' => 'Quiz result to evaluate feedback',
        ],
      ],
    ];
  }
  if (!isset($this->componentObject)) {
    $this->componentObject = RulesComponent::createFromConfiguration($this->component);
  }
  return $this->componentObject;
}