|
4 | 4 |
|
5 | 5 | use Drupal\Core\Entity\EntityForm;
|
6 | 6 | use Drupal\Core\Form\FormStateInterface;
|
7 |
| -use Drupal\Core\Entity\Query\QueryFactory; |
8 | 7 | use Drupal\Core\Link;
|
| 8 | +use Drupal\Core\Entity\EntityTypeManagerInterface; |
9 | 9 | use Symfony\Component\DependencyInjection\ContainerInterface;
|
10 | 10 |
|
11 | 11 | /**
|
12 | 12 | * Form controller for registration types.
|
13 | 13 | */
|
14 | 14 | class RegistrationTypeForm extends EntityForm {
|
15 | 15 | /**
|
16 |
| - * @var \Drupal\Core\Entity\Query\QueryFactory |
| 16 | + * An instance of the entity type manager. |
| 17 | + * |
| 18 | + * @var \Drupal\Core\Entity\EntityTypeManagerInterface |
17 | 19 | */
|
18 |
| - protected $entityQueryFactory; |
| 20 | + protected $entityTypeManager; |
19 | 21 |
|
20 | 22 | /**
|
21 | 23 | * {@inheritdoc}
|
22 | 24 | */
|
23 |
| - public function __construct(QueryFactory $query_factory) { |
24 |
| - $this->entityQueryFactory = $query_factory; |
| 25 | + public function __construct(EntityTypeManagerInterface $entity_type_manager) { |
| 26 | + $this->entityTypeManager = $entity_type_manager; |
25 | 27 | }
|
26 | 28 |
|
27 | 29 | /**
|
28 | 30 | * {@inheritdoc}
|
29 | 31 | */
|
30 | 32 | public static function create(ContainerInterface $container) {
|
31 |
| - return new static($container->get('entity.query')); |
| 33 | + return new static( |
| 34 | + $container->get('entity_type.manager') |
| 35 | + ); |
32 | 36 | }
|
33 | 37 |
|
34 | 38 | /**
|
@@ -80,7 +84,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
|
80 | 84 | * Callback for `id` form element in RegistrationTypeForm->buildForm.
|
81 | 85 | */
|
82 | 86 | public function exists($entity_id, array $element, FormStateInterface $form_state) {
|
83 |
| - $query = $this->entityQueryFactory->get('registration_type'); |
| 87 | + $query = $this->entityTypeManager->getStorage('registration_type')->getQuery(); |
84 | 88 | return (bool) $query->condition('id', $entity_id)->execute();
|
85 | 89 | }
|
86 | 90 |
|
|
0 commit comments