diff --git a/src/Block/Service/GDPRInformationBlockService.php b/src/Block/Service/GDPRInformationBlockService.php index e354ced8..10eaff73 100644 --- a/src/Block/Service/GDPRInformationBlockService.php +++ b/src/Block/Service/GDPRInformationBlockService.php @@ -37,9 +37,9 @@ final class GDPRInformationBlockService extends AbstractBlockService implements */ private $request; - public function __construct(string $name, EngineInterface $templating, RequestStack $request) + public function __construct(EngineInterface $templating, RequestStack $request) { - parent::__construct($name, $templating); + parent::__construct($templating); $this->request = $request; } @@ -106,11 +106,16 @@ public function validate(ErrorElement $errorElement, BlockInterface $block): voi public function getMetadata(): MetadataInterface { - return new Metadata($this->getName(), null, null, 'Core23GDPRBundle', [ + return new Metadata('core23_gdpr.block.information', null, null, 'Core23GDPRBundle', [ 'class' => 'fa fa-balance-scale', ]); } + public function getName(): string + { + return $this->getMetadata()->getTitle(); + } + private function hasGdprCookie(): bool { $request = $this->request->getMasterRequest(); diff --git a/src/Resources/config/block.xml b/src/Resources/config/block.xml index fc24b242..e9e060ec 100644 --- a/src/Resources/config/block.xml +++ b/src/Resources/config/block.xml @@ -3,7 +3,6 @@ - core23_gdpr.block.information diff --git a/tests/Block/Service/GDPRInformationBlockServiceTest.php b/tests/Block/Service/GDPRInformationBlockServiceTest.php index a2a4fdf8..4b7d1704 100644 --- a/tests/Block/Service/GDPRInformationBlockServiceTest.php +++ b/tests/Block/Service/GDPRInformationBlockServiceTest.php @@ -45,7 +45,7 @@ protected function setUp(): void public function testDefaultSettings(): void { - $blockService = new GDPRInformationBlockService('block.service', $this->templating, $this->requestStack); + $blockService = new GDPRInformationBlockService($this->templating, $this->requestStack); $blockContext = $this->getBlockContext($blockService); $this->assertSettings([ @@ -67,7 +67,7 @@ public function testExecute(): void 'position' => 'block', ]); - $blockService = new GDPRInformationBlockService('block.service', $this->templating, $this->requestStack); + $blockService = new GDPRInformationBlockService($this->templating, $this->requestStack); $blockService->execute($blockContext); static::assertSame('@Core23GDPR/Block/block_gdpr.html.twig', $this->templating->view); @@ -90,7 +90,7 @@ public function testExecuteWithExistingCookie(): void 'position' => 'block', ]); - $blockService = new GDPRInformationBlockService('block.service', $this->templating, $this->requestStack); + $blockService = new GDPRInformationBlockService($this->templating, $this->requestStack); $response = $blockService->execute($blockContext); static::assertTrue($response->isEmpty()); @@ -98,11 +98,11 @@ public function testExecuteWithExistingCookie(): void public function testGetMetadata(): void { - $blockService = new GDPRInformationBlockService('block.service', $this->templating, $this->requestStack); + $blockService = new GDPRInformationBlockService($this->templating, $this->requestStack); $metadata = $blockService->getMetadata(); - static::assertSame('block.service', $metadata->getTitle()); + static::assertSame('core23_gdpr.block.information', $metadata->getTitle()); static::assertNotNull($metadata->getImage()); static::assertStringStartsWith('data:image/png;base64,', $metadata->getImage() ?? ''); static::assertSame('Core23GDPRBundle', $metadata->getDomain()); @@ -113,7 +113,7 @@ public function testGetMetadata(): void public function testConfigureEditForm(): void { - $blockService = new GDPRInformationBlockService('block.service', $this->templating, $this->requestStack); + $blockService = new GDPRInformationBlockService($this->templating, $this->requestStack); $block = new Block();