Skip to content

Commit

Permalink
1145: Added project main page fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
rimi-itk committed Apr 13, 2024
1 parent 25514b6 commit ec93d9e
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

* [PR-395](https://github.com/itk-dev/hoeringsportal/pull/395)
Project fixtures
* [PR-398](https://github.com/itk-dev/hoeringsportal/pull/398)
Added Deskpro test data
* [pr-394](https://github.com/itk-dev/hoeringsportal/pull/394)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Hoeringsportal project fixtures
type: module
description: 'Provides project fixtures for the site.'
core_version_requirement: ^10
package: ITK
dependencies:
- content_fixtures:content_fixtures
- hoeringsportal_base_fixtures:hoeringsportal_base_fixtures
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
services:
Drupal\hoeringsportal_project_fixtures\Fixture\ProjectMainPageFixture:
tags:
- { name: content_fixture }
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<?php

namespace Drupal\hoeringsportal_project_fixtures\Fixture;

use Drupal\content_fixtures\Fixture\AbstractFixture;
use Drupal\content_fixtures\Fixture\DependentFixtureInterface;
use Drupal\content_fixtures\Fixture\FixtureGroupInterface;
use Drupal\hoeringsportal_base_fixtures\Fixture\MediaFixture;
use Drupal\hoeringsportal_base_fixtures\Fixture\ParagraphFixture;
use Drupal\node\Entity\Node;
use Drupal\paragraphs\Entity\Paragraph;

/**
* Landing page fixture.
*
* @package Drupal\hoeringsportal_project_fixtures\Fixture
*/
class ProjectMainPageFixture extends AbstractFixture implements DependentFixtureInterface, FixtureGroupInterface {

/**
* {@inheritdoc}
*/
public function load() {
// Project main page.
$entity = Node::create([
'type' => 'project_main_page',
])
->setTitle('Project')
->set('field_short_description', 'This is the first project')
->set(
'field_project_image',
[
['target_id' => $this->getReference('media:Medium1')->id()],
]
)
->set(
'body',
[
'value' => <<<'BODY'
<p>This project is the very first project, and will focus on some <strong>stuff</strong>.</p>
BODY,
'format' => 'filtered_html',
],
);

$paragraph = Paragraph::create([
'type' => 'image',
])
->set(
'field_paragraph_image',
[
['target_id' => $this->getReference('media:Medium2')->id()],
]
);
$paragraph->save();
$entity->field_content_sections->appendItem([
'target_id' => $paragraph->id(),
'target_revision_id' => $paragraph->getRevisionId(),
]);

$paragraph = Paragraph::create([
'type' => 'info_box',
])
->set('field_paragraph_title', 'Important!')
->set(
'field_content_block_text',
[
'value' => <<<'BODY'
<p>Beware that this is the <em>first</em> project.</p>
BODY,
'format' => 'filtered_html',
]
);
$paragraph->save();
$entity->field_content_sections->appendItem([
'target_id' => $paragraph->id(),
'target_revision_id' => $paragraph->getRevisionId(),
]);

$entity->save();
$this->addReference('node:project_main_page:1', $entity);

$entity = $entity->createDuplicate();
$entity
->setTitle('Another 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'
<p>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.</p>
<p>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.
</p>
BODY,
'format' => 'filtered_html',
],
);
$entity->save();
$this->addReference('node:project_main_page:2', $entity);
}

/**
* {@inheritdoc}
*/
public function getDependencies() {
return [
MediaFixture::class,
ParagraphFixture::class,
];
}

/**
* {@inheritdoc}
*/
public function getGroups() {
return ['node', 'project'];
}

}

0 comments on commit ec93d9e

Please sign in to comment.