Skip to content

Commit 3b99ed9

Browse files
committed
GH-291: Drupal 9 compatibility. Fix deprecated EntityManager.
1 parent a51f36b commit 3b99ed9

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
name: 'UI Patterns library theme test'
22
type: theme
33
core: 8.x
4+
base theme: stable

src/Plugin/UiPatterns/Source/FieldSource.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Drupal\ui_patterns\Plugin\UiPatterns\Source;
44

5-
use Drupal\Core\Entity\EntityManager;
5+
use Drupal\Core\Entity\EntityFieldManager;
66
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
77
use Drupal\ui_patterns\Plugin\PatternSourceBase;
88
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -24,16 +24,16 @@ class FieldSource extends PatternSourceBase implements ContainerFactoryPluginInt
2424
/**
2525
* Entity manager service.
2626
*
27-
* @var \Drupal\Core\Entity\EntityManager
27+
* @var \Drupal\Core\Entity\EntityFieldManager
2828
*/
29-
protected $entityManager;
29+
protected $entityFieldManager;
3030

3131
/**
3232
* {@inheritdoc}
3333
*/
34-
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManager $entity_manager) {
34+
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityFieldManager $entity_manager) {
3535
parent::__construct($configuration, $plugin_id, $plugin_definition);
36-
$this->entityManager = $entity_manager;
36+
$this->entityFieldManager = $entity_manager;
3737
}
3838

3939
/**
@@ -44,7 +44,7 @@ public static function create(ContainerInterface $container, array $configuratio
4444
$configuration,
4545
$plugin_id,
4646
$plugin_definition,
47-
$container->get('entity.manager')
47+
$container->get('entity_field.manager')
4848
);
4949
}
5050

@@ -53,7 +53,7 @@ public static function create(ContainerInterface $container, array $configuratio
5353
*/
5454
public function getSourceFields() {
5555
$sources = [];
56-
$fields = $this->entityManager->getFieldDefinitions($this->getContextProperty('entity_type'), $this->getContextProperty('entity_bundle'));
56+
$fields = $this->entityFieldManager->getFieldDefinitions($this->getContextProperty('entity_type'), $this->getContextProperty('entity_bundle'));
5757

5858
/** @var \Drupal\Core\Field\FieldDefinitionInterface $field */
5959
foreach ($fields as $field) {

ui_patterns.info.yml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: UI Patterns
22
type: module
33
description: UI patterns
44
core: 8.x
5+
core_version_requirement: ^8 || ^9
56
package: User interface
67
dependencies:
78
- drupal:system (>=8.3.0)

0 commit comments

Comments
 (0)