|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Drupal\os2loop_documents_fixtures\Fixture; |
| 4 | + |
| 5 | +use Drupal\content_fixtures\Fixture\AbstractFixture; |
| 6 | +use Drupal\content_fixtures\Fixture\DependentFixtureInterface; |
| 7 | +use Drupal\content_fixtures\Fixture\FixtureGroupInterface; |
| 8 | +use Drupal\node\Entity\Node; |
| 9 | +use Drupal\os2loop_taxonomy_fixtures\Fixture\ProfessionFixture; |
| 10 | +use Drupal\os2loop_taxonomy_fixtures\Fixture\SubjectFixture; |
| 11 | +use Drupal\os2loop_taxonomy_fixtures\Fixture\TagFixture; |
| 12 | +use Drupal\paragraphs\Entity\Paragraph; |
| 13 | + |
| 14 | +/** |
| 15 | + * Document fixture. |
| 16 | + * |
| 17 | + * @package Drupal\os2loop_documents_fixtures\Fixture |
| 18 | + */ |
| 19 | +class DocumentTOCFixture extends AbstractFixture implements DependentFixtureInterface, FixtureGroupInterface { |
| 20 | + |
| 21 | + /** |
| 22 | + * {@inheritdoc} |
| 23 | + */ |
| 24 | + public function load() { |
| 25 | + $document = Node::create([ |
| 26 | + 'type' => 'os2loop_documents_document', |
| 27 | + 'title' => 'Document with table of contents', |
| 28 | + 'os2loop_documents_document_autho' => 'Document Author', |
| 29 | + 'os2loop_shared_subject' => [ |
| 30 | + 'target_id' => $this->getReference('os2loop_subject:Diverse')->id(), |
| 31 | + ], |
| 32 | + 'os2loop_shared_tags' => [ |
| 33 | + ['target_id' => $this->getReference('os2loop_tag:test')->id()], |
| 34 | + ], |
| 35 | + 'os2loop_shared_profession' => [ |
| 36 | + 'target_id' => $this->getReference('os2loop_profession:Andet')->id(), |
| 37 | + ], |
| 38 | + ]); |
| 39 | + |
| 40 | + $paragraph = Paragraph::create([ |
| 41 | + 'type' => 'table_of_contents', |
| 42 | + 'table_of_contents' => 'os2loop_toc_block', |
| 43 | + ]); |
| 44 | + $paragraph->save(); |
| 45 | + $document->get('os2loop_documents_document_conte')->appendItem($paragraph); |
| 46 | + |
| 47 | + $paragraph = Paragraph::create([ |
| 48 | + 'type' => 'os2loop_documents_text_and_image', |
| 49 | + 'os2loop_documents_title' => 'Far who next them times the our multitude a life', |
| 50 | + 'os2loop_documents_tai_text' => [ |
| 51 | + 'value' => <<<'BODY' |
| 52 | +Lots and from touch clear the to her more hearts screen. Brief would affects will his little no in copy how don't the at the reached searched ear I the a in misleads rung as, and attempt, must lead be as chest he want spirit, may history; Dressed be which. |
| 53 | +BODY, |
| 54 | + 'format' => 'os2loop_documents_rich_text', |
| 55 | + ], |
| 56 | + ]); |
| 57 | + $paragraph->save(); |
| 58 | + $document->get('os2loop_documents_document_conte')->appendItem($paragraph); |
| 59 | + |
| 60 | + $document->save(); |
| 61 | + } |
| 62 | + |
| 63 | + /** |
| 64 | + * {@inheritdoc} |
| 65 | + */ |
| 66 | + public function getDependencies() { |
| 67 | + return [ |
| 68 | + SubjectFixture::class, |
| 69 | + TagFixture::class, |
| 70 | + ProfessionFixture::class, |
| 71 | + ]; |
| 72 | + } |
| 73 | + |
| 74 | + /** |
| 75 | + * {@inheritdoc} |
| 76 | + */ |
| 77 | + public function getGroups() { |
| 78 | + return ['os2loop_documents']; |
| 79 | + } |
| 80 | + |
| 81 | +} |
0 commit comments