Browse Source

Code clean-up

merge-requests/17/head 3.2.0
Chi 2 years ago
parent
commit
8aa63ea1f2
  1. 4
      src/TwigTweakExtension.php

4
src/TwigTweakExtension.php

@ -183,8 +183,8 @@ class TwigTweakExtension extends AbstractExtension {
*/ */
public static function drupalEntityForm(string $entity_type, ?string $id = NULL, string $form_mode = 'default', array $values = [], bool $check_access = TRUE): array { public static function drupalEntityForm(string $entity_type, ?string $id = NULL, string $form_mode = 'default', array $values = [], bool $check_access = TRUE): array {
$entity_storage = \Drupal::entityTypeManager()->getStorage($entity_type); $entity_storage = \Drupal::entityTypeManager()->getStorage($entity_type);
$entity_repository = \Drupal::service('entity.repository'); $entity = $id ?
$entity = $id ? $entity_repository->getActive($entity_type, $id) : $entity_storage->create($values); \Drupal::service('entity.repository')->getActive($entity_type, $id) : $entity_storage->create($values);
if ($entity) { if ($entity) {
return \Drupal::service('twig_tweak.entity_form_view_builder') return \Drupal::service('twig_tweak.entity_form_view_builder')
->build($entity, $form_mode, $check_access); ->build($entity, $form_mode, $check_access);

Loading…
Cancel
Save