Upgraded imagemagick and manually altered pdf to image module to handle changes....
[yaffs-website] / web / modules / contrib / paragraphs / modules / paragraphs_demo / paragraphs_demo.install
1 <?php
2 /**
3  * @file
4  * Installation hooks for paragraphs_demo module.
5  */
6
7 use Drupal\node\Entity\Node;
8 use Drupal\paragraphs\Entity\Paragraph;
9
10 /**
11  * Implements hook_install().
12  */
13 function paragraphs_demo_install() {
14   // Ensure the translation fields are created in the database.
15   \Drupal::service('entity.definition_update_manager')->applyUpdates();
16
17   // Create three paragraphs to structure the content.
18   $paragraph = Paragraph::create([
19     'title' => 'Paragraph 1',
20     'type' => 'text',
21     'field_text_demo' => [
22       'value' => '<h2>Paragraphs is the new way of content creation!</h2>
23       <p>It allows you — Site Builders — to make things cleaner so that you can give more editing power to your end-users.
24       Instead of putting all their content in one WYSIWYG body field including images and videos, end-users can now choose on-the-fly between pre-defined Paragraph Types independent from one another. Paragraph Types can be anything you want from a simple text block or image to a complex and configurable slideshow.</p>',
25       'format' => 'basic_html',
26     ],
27   ]);
28   $paragraph->save();
29
30   $paragraph2 = Paragraph::create([
31     'title' => 'Paragraph 2',
32     'type' => 'text',
33     'field_text_demo' => [
34       'value' => '<p>This demo creates some default Paragraph types from which you can easily create some content (Nested Paragraph, Text, Image + Text, Text + Image, Image and User). It also includes some basic styling and assures that the content is responsive on any device.</p>',
35       'format' => 'basic_html',
36     ],
37   ]);
38   $paragraph2->save();
39
40   $paragraph3 = Paragraph::create([
41     'title' => 'Paragraph 3',
42     'type' => 'text',
43     'field_text_demo' => [
44       'value' => '<p>Apart from the included Paragraph types, you can create your own simply by going to Structure -> Paragraphs types.</p>',
45       'format' => 'basic_html',
46     ],
47   ]);
48   $paragraph3->save();
49
50   $paragraph4 = Paragraph::create([
51     'title' => 'Paragraph 4',
52     'type' => 'text',
53     'field_text_demo' => [
54       'value' => '<p>A search api example can be found <a href="/paragraphs_search">here</a></p>',
55       'format' => 'basic_html',
56     ],
57   ]);
58   $paragraph4->save();
59
60   $paragraph5 = Paragraph::create([
61     'title' => 'Paragraph 4',
62     'type' => 'nested_paragraph',
63     'field_paragraphs_demo' => $paragraph4,
64   ]);
65   $paragraph5->save();
66
67   // Add demo content with four paragraphs.
68   $node = Node::create(array(
69     'type' => 'paragraphed_content_demo',
70     'title' => 'Welcome to the Paragraphs Demo module!',
71     'langcode' => 'en',
72     'uid' => '0',
73     'status' => 1,
74     'field_paragraphs_demo' => array(
75       array(
76         'target_id' => $paragraph->id(),
77         'target_revision_id' => $paragraph->getRevisionId(),
78       ),
79       array(
80         'target_id' => $paragraph2->id(),
81         'target_revision_id' => $paragraph2->getRevisionId(),
82       ),
83       array(
84         'target_id' => $paragraph3->id(),
85         'target_revision_id' => $paragraph3->getRevisionId(),
86       ),
87       array(
88         'target_id' => $paragraph5->id(),
89         'target_revision_id' => $paragraph5->getRevisionId(),
90       ),
91     ),
92   ));
93   $node->save();
94   // Set the node as the front page.
95   \Drupal::configFactory()->getEditable('system.site')->set('page.front', '/node/' . $node->id())->save();
96 }