class TransactionInlineForm in Transaction 8
Defines the inline form for the transaction entity.
Hierarchy
- class \Drupal\inline_entity_form\Form\EntityInlineForm implements InlineFormInterface uses StringTranslationTrait
- class \Drupal\transaction_ief\Form\TransactionInlineForm
Expanded class hierarchy of TransactionInlineForm
1 file declares its use of TransactionInlineForm
- transaction_ief.module in modules/
transaction_ief/ transaction_ief.module
File
- modules/
transaction_ief/ src/ Form/ TransactionInlineForm.php, line 18
Namespace
Drupal\transaction_ief\FormView source
class TransactionInlineForm extends EntityInlineForm {
/**
* The route match.
*
* @var \Drupal\Core\Routing\RouteMatchInterface
*/
protected $routeMatch;
/**
* The request stack.
*
* @var \Symfony\Component\HttpFoundation\RequestStack
*/
protected $requestStack;
/**
* Constructs the inline entity form controller.
*
* @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager
* The entity field manager.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The route match.
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
* The request stack.
*/
public function __construct(EntityFieldManagerInterface $entity_field_manager, EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, EntityTypeInterface $entity_type, RouteMatchInterface $route_match, RequestStack $request_stack) {
parent::__construct($entity_field_manager, $entity_type_manager, $module_handler, $entity_type);
$this->routeMatch = $route_match;
$this->requestStack = $request_stack;
}
/**
* {@inheritdoc}
*/
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static($container
->get('entity_field.manager'), $container
->get('entity_type.manager'), $container
->get('module_handler'), $entity_type, $container
->get('current_route_match'), $container
->get('request_stack'));
}
/**
* {@inheritdoc}
*/
public function entityForm(array $entity_form, FormStateInterface $form_state) {
/** @var \Drupal\transaction\TransactionInterface $transaction */
$transaction = $entity_form['#entity'];
// Discover the target entity by examining the current route or by getting
// from the request argument with the same name as the target entity type.
if (!$transaction
->getTargetEntityId()) {
$route_options = $this->routeMatch
->getRouteObject()
->getOptions();
$target_entity_type_id = isset($route_options['_transaction_target_entity_type_id']) ? $route_options['_transaction_target_entity_type_id'] : $transaction
->getType()
->getTargetEntityTypeId();
if ($target_entity = $this->requestStack
->getCurrentRequest()
->get($target_entity_type_id)) {
$transaction
->setTargetEntity($target_entity);
}
}
return parent::entityForm($entity_form, $form_state);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityInlineForm:: |
protected | property | The entity field manager. | |
EntityInlineForm:: |
protected | property | The entity type managed by this handler. | |
EntityInlineForm:: |
protected | property | The entity type manager. | |
EntityInlineForm:: |
protected | property | Module handler service. | |
EntityInlineForm:: |
protected | function | Builds an updated entity object based upon the submitted form values. | |
EntityInlineForm:: |
public | function |
Delete permanently saved entities. Overrides InlineFormInterface:: |
|
EntityInlineForm:: |
public | function |
Handles the submission of an entity form. Overrides InlineFormInterface:: |
|
EntityInlineForm:: |
public | function |
Validates the entity form. Overrides InlineFormInterface:: |
|
EntityInlineForm:: |
public | function |
Gets the label of the given entity. Overrides InlineFormInterface:: |
|
EntityInlineForm:: |
public | function |
Gets the entity type managed by this handler. Overrides InlineFormInterface:: |
|
EntityInlineForm:: |
public | function |
Gets the entity type labels (singular, plural). Overrides InlineFormInterface:: |
1 |
EntityInlineForm:: |
protected | function | Gets the form display for the given entity. | |
EntityInlineForm:: |
public | function |
Gets the columns used to represent an entity in the IEF table. Overrides InlineFormInterface:: |
1 |
EntityInlineForm:: |
public | function |
Checks whether tabledrag should be enabled for the given table. Overrides InlineFormInterface:: |
|
EntityInlineForm:: |
public | function |
Saves the given entity. Overrides InlineFormInterface:: |
|
EntityInlineForm:: |
public static | function | Cleans up the form state for a submitted entity form. | |
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. | |
TransactionInlineForm:: |
protected | property | The request stack. | |
TransactionInlineForm:: |
protected | property | The route match. | |
TransactionInlineForm:: |
public static | function |
Instantiates a new instance of this entity handler. Overrides EntityInlineForm:: |
|
TransactionInlineForm:: |
public | function |
Builds the entity form. Overrides EntityInlineForm:: |
|
TransactionInlineForm:: |
public | function |
Constructs the inline entity form controller. Overrides EntityInlineForm:: |