/**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     foreach ($this->typedDataManager->getDefinitions() as $data_type_id => $data_type_definition) {
         if (is_subclass_of($data_type_definition['class'], ComplexDataInterface::class, TRUE)) {
             /** @var \Drupal\Core\TypedData\ComplexDataDefinitionInterface $base_definition */
             $base_definition = $this->typedDataManager->createDataDefinition($data_type_id);
             foreach ($base_definition->getPropertyDefinitions() as $property_name => $property_definition) {
                 if ($property_definition instanceof BaseFieldDefinition || $property_definition instanceof FieldConfig) {
                     $this->generateDerivativeDefinition($base_plugin_definition, $data_type_id, $data_type_definition, $base_definition, $property_name, $property_definition);
                 }
             }
         }
     }
     return $this->derivatives;
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $cached_values = $form_state->getTemporaryValue('wizard');
     $this->machine_name = $cached_values['id'];
     $form['items'] = array('#type' => 'markup', '#prefix' => '<div id="configured-contexts">', '#suffix' => '</div>', '#theme' => 'table', '#header' => array($this->t('Context ID'), $this->t('Label'), $this->t('Data Type'), $this->t('Options')), '#rows' => $this->renderRows($cached_values), '#empty' => t('No contexts or relationships have been added.'));
     foreach ($this->typedDataManager->getDefinitions() as $type => $definition) {
         $types[$type] = $definition['label'];
     }
     if (isset($types['entity'])) {
         unset($types['entity']);
     }
     asort($types);
     $form['context'] = ['#type' => 'select', '#options' => $types];
     $form['add'] = ['#type' => 'submit', '#name' => 'add', '#value' => $this->t('Add new context'), '#ajax' => ['callback' => [$this, 'addContext'], 'event' => 'click'], '#submit' => ['callback' => [$this, 'submitForm']]];
     $form['relationships'] = ['#type' => 'select', '#title' => $this->t('Add a relationship'), '#options' => $this->getAvailableRelationships($cached_values), '#access' => $this->relationships];
     $form['add_relationship'] = ['#type' => 'submit', '#name' => 'add_relationship', '#value' => t('Add Relationship'), '#ajax' => ['callback' => [$this, 'addRelationship'], 'event' => 'click'], '#submit' => ['callback' => [$this, 'submitForm']], '#access' => $this->relationships];
     return $form;
 }
 /**
  * Builds an array of options for the parameter type.
  *
  * @return array[]
  *   A multidimensional array. The top level is keyed by group ('Content',
  *   'Configuration', 'Typed Data'). Those values are an array of type labels,
  *   keyed by the machine name.
  */
 protected function buildParameterTypeOptions()
 {
     $options = [static::NO_CONTEXT_KEY => $this->t('No context selected')];
     // Make a grouped, sorted list of entity type options. Key the inner array
     // to use the typed data format of 'entity:$entity_type_id'.
     foreach ($this->entityTypeRepository->getEntityTypeLabels(TRUE) as $group_label => $grouped_options) {
         foreach ($grouped_options as $key => $label) {
             $options[$group_label]['entity:' . $key] = $label;
         }
     }
     $primitives_label = (string) $this->t('Primitives');
     foreach ($this->typedDataManager->getDefinitions() as $key => $definition) {
         if (is_subclass_of($definition['class'], PrimitiveInterface::class)) {
             $options[$primitives_label][$key] = $definition['label'];
         }
     }
     asort($options[$primitives_label], SORT_NATURAL);
     return $options;
 }