Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / modules / contrib / paragraphs / modules / paragraphs_demo / paragraphs_demo.module
1 <?php
2
3 /**
4  * @file
5  * Contains paragraphs_demo.module
6  */
7
8 use Drupal\Core\Url;
9 use Drupal\Core\Routing\RouteMatchInterface;
10
11 /**
12  * Implements hook_help().
13  */
14 function paragraphs_demo_help($route_name, RouteMatchInterface $route_match) {
15   switch ($route_name) {
16     // Help for the paragraphs demo module.
17     case 'help.page.paragraphs_demo':
18       $output = '';
19       $output .= '<h3>' . t('About') . '</h3>';
20       $output .= '<p>' . t('The Paragraphs Demo module provides several <em>Paragraphs types</em> for the <a href=":paragraphs">Paragraphs module</a>, but no separate user interface. For more information, see the <a href=":online">online documentation for the Paragraphs module</a>.', [':online' => 'https://www.drupal.org/node/2444881', ':paragraphs' => Url::fromRoute('help.page', ['name' => 'paragraphs'])->toString()]) . '</p>';
21       $output .= '<h3>' . t('Uses') . '</h3>';
22       $output .= '<dt>' . t('Changing demo Paragraphs types') . '</dt>';
23       $output .= '<dd>' . t('Administrators can edit the provided <em>Paragraphs types</em> on the <a href=":paragraphs">Paragraphs types page</a> if the <a href=":field_ui">Field UI</a> module is enabled. For more information on fields and entities, see the <a href=":field">Field module help page</a>.', [':paragraphs' => Url::fromRoute('entity.paragraphs_type.collection')->toString(), ':field' => Url::fromRoute('help.page', ['name' => 'field'])->toString(), ':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? Url::fromRoute('help.page', ['name' => 'field_ui'])->toString() : '#']) . '</dd>';
24       $output .= '<dt>' . t('Deleting demo Paragraphs types') . '</dt>';
25       $output .= '<dd>' . t('The provided <em>demo Paragraph types</em> stay available even when the Paragraphs Demo module is uninstalled. They can be deleted individually on the <a href=":paragraphs">Paragraphs types page</a>.', [':paragraphs' => Url::fromRoute('entity.paragraphs_type.collection')->toString()]) . '</dd>';
26       return $output;
27     break;
28   }
29 }
30
31 /**
32  * Implements hook_preprocess_node() for paragraph node templates.
33  *
34  * Attach css we need for paragraph demo content.
35  */
36 function paragraphs_demo_preprocess_node(&$variables) {
37   // If more general approach is needed then implement preprocessor for
38   // paragraph.html.twig.
39   if ($variables['node']->getType() === 'paragraphed_content_demo') {
40     $variables['#attached']['library'][] = 'paragraphs_demo/drupal.paragraphs_demo';
41   }
42 }