Created
September 22, 2021 20:24
-
-
Save neclimdul/9719e21fc7fe162ca8d3080d9aad362f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Drupal\my_custom; | |
use Drupal\my_custom\Normalizer\FileEntityNormalizer; | |
use Drupal\Core\DependencyInjection\ContainerBuilder; | |
use Drupal\Core\DependencyInjection\ServiceProviderBase; | |
use Symfony\Component\DependencyInjection\Definition; | |
use Symfony\Component\DependencyInjection\Reference; | |
/** | |
* Remove file normalizers that are causing problems. | |
*/ | |
class TestServiceProvider extends ServiceProviderBase { | |
/** | |
* {@inheritdoc} | |
*/ | |
public function alter(ContainerBuilder $container) { | |
// Make sure definition exists before we replace. It might not in certain | |
// testing conditions. | |
if ($container->has('serializer.normalizer.entity.file_entity')) { | |
// Replace file normalizer with one that doesn't include actual files. | |
$service_definition = new Definition(FileEntityNormalizer::class, [ | |
new Reference('hal.link_manager'), | |
new Reference('entity.manager'), | |
new Reference('module_handler'), | |
]); | |
// The priority must be higher than that of | |
// serializer.normalizer.file_entity.hal in hal.services.yml. | |
$service_definition->addTag('normalizer', ['priority' => 30]); | |
$container->setDefinition('serializer.normalizer.entity.file_entity', $service_definition); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There are two d9 upgrade failures here. I don't know what of them are testable its an interesting edge case for upgrade failures.