|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @file |
|
5
|
|
|
* Provides preprocess logic for example paragraph types. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
use Drupal\Component\Utility\Html; |
|
|
|
|
|
|
9
|
|
|
use Drupal\paragraphs_editor\Utility\RenderUtility; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Implements hook_theme(). |
|
13
|
|
|
*/ |
|
14
|
|
|
function paragraphs_editor_examples_theme($existing) { |
|
15
|
|
|
// This hook would not be necessary if the preprocess hooks were implemented |
|
16
|
|
|
// in the theme layer. |
|
17
|
|
|
$theme = []; |
|
18
|
|
|
$template_path = drupal_get_path('module', 'paragraphs_editor_examples') . '/templates'; |
|
|
|
|
|
|
19
|
|
|
$theme['paragraph__tabs'] = $existing['paragraph']; |
|
20
|
|
|
$theme['paragraph__tabs']['template'] = 'paragraph--tabs'; |
|
21
|
|
|
$theme['paragraph__tabs']['path'] = $template_path; |
|
22
|
|
|
return $theme; |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Implements hook_preprocess_paragraph__tabs(). |
|
27
|
|
|
*/ |
|
28
|
|
|
function paragraphs_editor_examples_preprocess_paragraph__tabs(array &$variables) { |
|
29
|
|
|
// Attach the tab javascript. |
|
30
|
|
|
$variables['#attached']['library'][] = 'paragraphs_editor_examples/tabs'; |
|
31
|
|
|
|
|
32
|
|
|
// Use the tabs entity to build the content to be rendered. |
|
33
|
|
|
$tabs = $variables['elements']['#paragraph']; |
|
34
|
|
|
$variables['content'] = []; |
|
35
|
|
|
foreach ($tabs->field_tabs as $delta => $tab) { |
|
36
|
|
|
$variables['content']['field_tabs'][$delta] = [ |
|
37
|
|
|
'id' => Html::getId('tabs-' . $delta), |
|
38
|
|
|
'link' => [ |
|
39
|
|
|
'title' => $tab->entity->field_title->value, |
|
40
|
|
|
], |
|
41
|
|
|
]; |
|
42
|
|
|
|
|
43
|
|
|
// Attach inline editing data to the tab. We have to do this since we aren't |
|
44
|
|
|
// going to directly render the 'field_content' field in the twig template. |
|
45
|
|
|
RenderUtility::getEditableData($variables, $tab->entity->field_content) |
|
46
|
|
|
->preprocessField($variables['content']['field_tabs'][$delta]); |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths