You are here

public function VotingApiLoader::buildForm in Votingapi Widgets 8

Build rate form.

File

src/VotingApiLoader.php, line 44

Class

VotingApiLoader
Implements lazy loading.

Namespace

Drupal\votingapi_widgets

Code

public function buildForm($plugin_id, $entity_type, $entity_bundle, $entity_id, $vote_type, $field_name, $settings) {
  $definitions = $this->widgetManager
    ->getDefinitions();
  $entity = $this->entityTypeManager
    ->getStorage($entity_type)
    ->load($entity_id);
  $plugin = $this->widgetManager
    ->createInstance($plugin_id, $definitions[$plugin_id]);
  $fieldDefinition = $entity->{$field_name}
    ->getFieldDefinition();
  if (empty($plugin) || empty($entity) || !$entity
    ->hasField($field_name)) {
    return [];
  }
  return $plugin
    ->buildForm($entity_type, $entity_bundle, $entity_id, $vote_type, $field_name, unserialize($settings));
}