summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjibran2018-09-06 16:10:49 (GMT)
committerJibran Ijaz2018-09-06 16:10:49 (GMT)
commitb9b16205aa55e8d18d898673757b61d72fb5365d (patch)
treeb1ca9dbb1e10f77316e4be9c7ef4a5504b10419d
parent3a6359784dc2434a5342ebe0a32c1546c192d603 (diff)
Issue #2970836 by jibran, das-peter, Berdir: Argument 3 passed to Drupal\hal\Normalizer\EntityReferenceItemNormalizer::__construct() must implement interface Drupal\Core\Entity\EntityTypeManagerInterface or be null8.x-2.0-alpha8
-rw-r--r--src/DynamicEntityReferenceServiceProvider.php23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/DynamicEntityReferenceServiceProvider.php b/src/DynamicEntityReferenceServiceProvider.php
index 1b7b635..338038c 100644
--- a/src/DynamicEntityReferenceServiceProvider.php
+++ b/src/DynamicEntityReferenceServiceProvider.php
@@ -6,6 +6,7 @@ use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceProviderBase;
use Drupal\Core\Entity\Query\Sql\QueryFactory as BaseQueryFactory;
use Drupal\Core\Entity\Query\Sql\pgsql\QueryFactory as BasePgsqlQueryFactory;
+use Drupal\dynamic_entity_reference\Normalizer\DynamicEntityReferenceItemNormalizer;
use Drupal\dynamic_entity_reference\Query\PgsqlQueryFactory;
use Drupal\dynamic_entity_reference\Query\QueryFactory;
use Symfony\Component\DependencyInjection\Definition;
@@ -21,18 +22,22 @@ class DynamicEntityReferenceServiceProvider extends ServiceProviderBase {
*/
public function alter(ContainerBuilder $container) {
$modules = $container->getParameter('container.modules');
- if (isset($modules['rest']) && isset($modules['serialization']) && isset($modules['hal'])) {
+ if (isset($modules['hal'])) {
+ // Hal module is enabled, add our new normalizer for dynamic entity
+ // reference items.
+ // To avoid problems the arguments to
+ // \Drupal\hal\Normalizer\EntityReferenceItemNormalizer change, re-use
+ // the same constructor arguments and set the additional dependency
+ // with a setter method.
+ $parent_definition = $container->getDefinition('serializer.normalizer.entity_reference_item.hal');
+ $service_definition = new Definition(DynamicEntityReferenceItemNormalizer::class, $parent_definition->getArguments());
- // Add a normalizer service for dynamic_entity_reference fields.
- $service_definition = new Definition('Drupal\dynamic_entity_reference\Normalizer\DynamicEntityReferenceItemNormalizer', [
- new Reference('rest.link_manager'),
- new Reference('serializer.entity_resolver'),
- new Reference('module_handler'),
- ]);
// The priority must be higher than that of
- // serializer.normalizer.entity_reference.hal in hal.services.yml.
- $service_definition->addTag('normalizer', ['priority' => 20]);
+ // serializer.normalizer.entity_reference_item.hal in
+ // hal.services.yml.
+ $service_definition->addTag('normalizer', array('priority' => $parent_definition->getTags()['normalizer'][0]['priority'] + 1));
$container->setDefinition('serializer.normalizer.entity.dynamic_entity_reference_item.hal', $service_definition);
+
}
$map = [
'entity.query.sql' => [