From 6467f87d567f6031df6385326cd279f0a5a83186 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Thu, 11 Apr 2024 17:02:15 +0200 Subject: [PATCH] 1145: Added block content fixtures --- ...eringsportal_project_fixtures.services.yml | 4 ++ .../src/Fixture/BlockContentFixture.php | 60 +++++++++++++++++++ .../src/Fixture/ProjectMainPageFixture.php | 33 +++++++++- 3 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 web/modules/custom/hoeringsportal_project/modules/hoeringsportal_project_fixtures/src/Fixture/BlockContentFixture.php diff --git a/web/modules/custom/hoeringsportal_project/modules/hoeringsportal_project_fixtures/hoeringsportal_project_fixtures.services.yml b/web/modules/custom/hoeringsportal_project/modules/hoeringsportal_project_fixtures/hoeringsportal_project_fixtures.services.yml index 9ed174f1..5b5dc18e 100644 --- a/web/modules/custom/hoeringsportal_project/modules/hoeringsportal_project_fixtures/hoeringsportal_project_fixtures.services.yml +++ b/web/modules/custom/hoeringsportal_project/modules/hoeringsportal_project_fixtures/hoeringsportal_project_fixtures.services.yml @@ -1,4 +1,8 @@ services: + Drupal\hoeringsportal_project_fixtures\Fixture\BlockContentFixture: + tags: + - { name: content_fixture } + Drupal\hoeringsportal_project_fixtures\Fixture\ProjectMainPageFixture: tags: - { name: content_fixture } diff --git a/web/modules/custom/hoeringsportal_project/modules/hoeringsportal_project_fixtures/src/Fixture/BlockContentFixture.php b/web/modules/custom/hoeringsportal_project/modules/hoeringsportal_project_fixtures/src/Fixture/BlockContentFixture.php new file mode 100644 index 00000000..2fd64b28 --- /dev/null +++ b/web/modules/custom/hoeringsportal_project/modules/hoeringsportal_project_fixtures/src/Fixture/BlockContentFixture.php @@ -0,0 +1,60 @@ + 'aside_contact_info', + ]) + ->setInfo('The main address') + ->set('field_department', 'Redundancy Department') + ->set('field_title', 'Department of Redundancy Department') + ->set('body', [ + 'value' => '

Department
Street No.
1234

', + ]) + ->set('field_phone_number', 1234567890) + ->set('field_email', 'ddepartment@example.com'); + + $entity->save(); + $this->addReference('block_content:the_main_address', $entity); + + $entity = BlockContent + ::create([ + 'type' => 'aside_contact_info', + ]) + ->setInfo('Another address') + ->set('field_department', 'The Department') + ->set('field_title', 'Title of the Department') + ->set('body', [ + 'value' => '

Street 87

', + ]) + ->set('field_phone_number', 2234455) + ->set('field_email', 'another@example.com'); + + $entity->save(); + $this->addReference('block_content:another_address', $entity); + } + + /** + * {@inheritdoc} + */ + public function getGroups() { + return ['block', 'project']; + } + +} diff --git a/web/modules/custom/hoeringsportal_project/modules/hoeringsportal_project_fixtures/src/Fixture/ProjectMainPageFixture.php b/web/modules/custom/hoeringsportal_project/modules/hoeringsportal_project_fixtures/src/Fixture/ProjectMainPageFixture.php index 32ae1f32..bff7f6c8 100644 --- a/web/modules/custom/hoeringsportal_project/modules/hoeringsportal_project_fixtures/src/Fixture/ProjectMainPageFixture.php +++ b/web/modules/custom/hoeringsportal_project/modules/hoeringsportal_project_fixtures/src/Fixture/ProjectMainPageFixture.php @@ -41,7 +41,10 @@ public function load() { BODY, 'format' => 'filtered_html', ], - ); + ) + ->set('field_aside_block', [ + ['target_id' => $this->getReference('block_content:the_main_address')->id()], + ]); $paragraph = Paragraph::create([ 'type' => 'image', @@ -103,6 +106,33 @@ public function load() { ); $entity->save(); $this->addReference('node:project_main_page:2', $entity); + + $entity = $entity->createDuplicate(); + $entity + ->setTitle('The third project') + ->set('field_short_description', 'We have more than one project') + ->set( + 'field_project_image', + [ + ['target_id' => $this->getReference('media:Map1')->id()], + ] + ) + ->set( + 'body', + [ + 'value' => <<<'BODY' +

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed luctus accumsan ante sit amet fermentum. Aliquam aliquet massa ut enim vulputate feugiat. Maecenas tincidunt risus rhoncus, interdum neque ac, aliquet ex. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Cras commodo, odio id scelerisque pulvinar, erat neque fringilla purus, non faucibus metus nibh ullamcorper arcu. In posuere magna ante, in cursus velit lacinia eu. Sed viverra blandit sem. Donec quam orci, tincidunt eget porttitor at, luctus eu est. In sed nulla mauris. Etiam arcu augue, accumsan vitae magna vel, interdum imperdiet magna.

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed luctus accumsan ante sit amet fermentum. Aliquam aliquet massa ut enim vulputate feugiat. Maecenas tincidunt risus rhoncus, interdum neque ac, aliquet ex. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Cras commodo, odio id scelerisque pulvinar, erat neque fringilla purus, non faucibus metus nibh ullamcorper arcu. In posuere magna ante, in cursus velit lacinia eu. Sed viverra blandit sem. Donec quam orci, tincidunt eget porttitor at, luctus eu est. In sed nulla mauris. Etiam arcu augue, accumsan vitae magna vel, interdum imperdiet magna. +

+BODY, + 'format' => 'filtered_html', + ], + ) + ->set('field_aside_block', [ + ['target_id' => $this->getReference('block_content:another_address')->id()], + ]); + ; + $entity->save(); } /** @@ -110,6 +140,7 @@ public function load() { */ public function getDependencies() { return [ + BlockContentFixture::class, MediaFixture::class, ParagraphFixture::class, ];