/**
* @return array
*/ publicfunctionproviderGetFormClass(){ $block_plugin_without_forms = newTestClass([], 'block_plugin_without_forms', [ 'provider' => 'block_test', ]); // A block plugin that has a form defined for the 'poke' operation.
/**
* {@inheritdoc}
*/ publicfunctiongetFormObject($entity_type_id, $operation){ if(!$class = $this->getDefinition($entity_type_id, TRUE)->getFormClass($operation)){ thrownewInvalidPluginDefinitionException($entity_type_id, sprintf('The "%s" entity type did not specify a "%s" form class.', $entity_type_id, $operation)); }
publicfunctioncreateInstance(PluginWithFormsInterface $plugin, $operation, $fallback_operation = NULL){ if(!$plugin->hasFormClass($operation)){ // Use the default form class if no form is specified for this operation.
if($fallback_operation && $plugin->hasFormClass($fallback_operation)){ $operation = $fallback_operation; } else{ thrownewInvalidPluginDefinitionException($plugin->getPluginId(), sprintf('The "%s" plugin did not specify a "%s" form class', $plugin->getPluginId(), $operation)); } }
$form_class = $plugin->getFormClass($operation);
// If the form specified is the plugin itself, use it directly.
if(ltrim(get_class($plugin), '\\') === ltrim($form_class, '\\')){ $form_object = $plugin; } else{ $form_object = $this->classResolver->getInstanceFromDefinition($form_class); }
// Ensure the resulting object is a plugin form.
if(!$form_object instanceof PluginFormInterface){
protectedfunctiongetAddFormRoute(EntityTypeInterface $entity_type){ if($entity_type->hasLinkTemplate('add-form')){ $entity_type_id = $entity_type->id(); $route = newRoute($entity_type->getLinkTemplate('add-form')); // Use the add form handler, if available, otherwise default.
$operation = 'default'; if($entity_type->getFormClass('add')){ $operation = 'add'; } $route->setDefaults([ '_entity_form' => "{$entity_type_id}.{$operation}", 'entity_type_id' => $entity_type_id, ]);
// If the entity has bundles, we can provide a bundle-specific title
// and access requirements.
$expected_parameter = $entity_type->getBundleEntityType() ?: $entity_type->getKey('bundle'); // @todo We have to check if a route contains a bundle in its path as