├── README.md
├── bricks.info.yml
├── bricks.libraries.yml
├── bricks.module
├── composer.json
├── js
└── tabledrag.relationship-all.js
├── modules
├── bricks_default
│ └── bricks_default.info.yml
├── bricks_default_blocks
│ ├── bricks_default_blocks.features.yml
│ ├── bricks_default_blocks.info.yml
│ ├── bricks_default_blocks.install
│ └── config
│ │ └── install
│ │ ├── block_content.type.image.yml
│ │ ├── block_content.type.layout.yml
│ │ ├── block_content.type.wrapper.yml
│ │ ├── core.entity_form_display.block_content.image.default.yml
│ │ ├── core.entity_form_display.block_content.layout.default.yml
│ │ ├── core.entity_form_display.block_content.wrapper.default.yml
│ │ ├── core.entity_form_display.node.bricky_blocks.default.yml
│ │ ├── core.entity_view_display.block_content.image.default.yml
│ │ ├── core.entity_view_display.block_content.layout.default.yml
│ │ ├── core.entity_view_display.node.bricky_blocks.default.yml
│ │ ├── core.entity_view_display.node.bricky_blocks.teaser.yml
│ │ ├── field.field.block_content.image.field_image.yml
│ │ ├── field.field.node.bricky_blocks.field_body_blocks.yml
│ │ ├── field.storage.block_content.field_image.yml
│ │ ├── field.storage.node.field_body_blocks.yml
│ │ └── node.type.bricky_blocks.yml
├── bricks_default_eck
│ ├── bricks_default_eck.features.yml
│ ├── bricks_default_eck.info.yml
│ ├── bricks_default_eck.install
│ └── config
│ │ └── install
│ │ ├── core.entity_form_display.basic.image.default.yml
│ │ ├── core.entity_form_display.basic.text.default.yml
│ │ ├── core.entity_form_display.node.bricky_eck.default.yml
│ │ ├── core.entity_view_display.basic.image.default.yml
│ │ ├── core.entity_view_display.basic.text.default.yml
│ │ ├── core.entity_view_display.basic.wrapper.default.yml
│ │ ├── core.entity_view_display.node.bricky_eck.default.yml
│ │ ├── core.entity_view_display.node.bricky_eck.teaser.yml
│ │ ├── eck.eck_entity_type.basic.yml
│ │ ├── eck.eck_type.basic.image.yml
│ │ ├── eck.eck_type.basic.layout.yml
│ │ ├── eck.eck_type.basic.text.yml
│ │ ├── eck.eck_type.basic.wrapper.yml
│ │ ├── field.field.basic.image.field_image.yml
│ │ ├── field.field.basic.text.field_text.yml
│ │ ├── field.field.node.bricky_eck.field_body_eck.yml
│ │ ├── field.storage.basic.field_image.yml
│ │ ├── field.storage.basic.field_text.yml
│ │ ├── field.storage.node.field_body_eck.yml
│ │ └── node.type.bricky_eck.yml
├── bricks_default_paragraphs
│ ├── bricks_default_paragraphs.features.yml
│ ├── bricks_default_paragraphs.info.yml
│ ├── bricks_default_paragraphs.install
│ └── config
│ │ └── install
│ │ ├── core.entity_form_display.node.bricky_paragraphs.default.yml
│ │ ├── core.entity_view_display.node.bricky_paragraphs.default.yml
│ │ ├── core.entity_view_display.node.bricky_paragraphs.teaser.yml
│ │ ├── field.field.node.bricky_paragraphs.field_body_paragraphs.yml
│ │ ├── field.storage.node.field_body_paragraphs.yml
│ │ ├── node.type.bricky_paragraphs.yml
│ │ ├── paragraphs.paragraphs_type.layout.yml
│ │ └── paragraphs.paragraphs_type.wrapper.yml
├── bricks_dynamic
│ ├── bricks_dynamic.info.yml
│ ├── bricks_dynamic.module
│ └── src
│ │ └── Plugin
│ │ └── Field
│ │ ├── FieldFormatter
│ │ └── BricksNestedDynamicFormatter.php
│ │ ├── FieldType
│ │ └── BricksTreeDynamicItem.php
│ │ └── FieldWidget
│ │ ├── BricksTreeDynamicInlineWidget.php
│ │ └── BricksTreeDynamicWidget.php
├── bricks_inline
│ ├── bricks_inline.info.yml
│ ├── bricks_inline.module
│ └── src
│ │ └── Plugin
│ │ └── Field
│ │ └── FieldWidget
│ │ └── BricksTreeInlineWidget.php
└── bricks_revisions
│ ├── bricks_revisions.info.yml
│ └── src
│ └── Plugin
│ └── Field
│ └── FieldType
│ └── BricksTreeRevisionedItem.php
└── src
└── Plugin
└── Field
├── FieldFormatter
└── BricksNestedFormatter.php
├── FieldType
└── BricksTreeItem.php
└── FieldWidget
└── BricksTreeAutocompleteWidget.php
/README.md:
--------------------------------------------------------------------------------
1 | # Bricks
2 |
3 | [](https://timezone.io/team/drupal-bricks)
4 | [](https://twitter.com/highwebtech/status/841004866633842689)
5 |
6 | **Bricks** — is a new way of building pages on top of Entity Reference, Display Modes, Layout API, tabledrag.js and [Flat Tables](http://evolt.org/node/4047#table). Everything is in Drupal core that makes Bricks ultra-lightweight and developer-friendly.
7 |
8 | In terms of concept Bricks is a new generation of Paragraphs, an alternative to Panelizer and a good friend to ECK, Inline Entity Form and your favorite WYSIWYG. Shortly, it allows you to nest Entity Reference field items using Drupal drag & drop UI (exactly like for menu or taxonomy items).
9 |
10 |
11 |
12 |
13 | ## Live demo
14 |
15 | 1. Open [pre-configured sandbox](https://simplytest.me/project/bricks).
16 | 2. Click **Launch sandbox** and wait.
17 | 3. Follow the installation (all settings should be pre-filled, don't change them).
18 | 4. Go to **Extend** and enable **Bootstrap Kit Demo**.
19 | 5. Go to **Appearance** and set **Tweme** as default theme.
20 | 6. Find an auto-created node and go to **Edit** mode to check magic out!
21 | 7. Finally go to **Content** and create your own first **Bricky** page!
22 | 8. Like it? => Support by [★ starring on Drupal.org](https://www.drupal.org/project/bricks), [★ starring on GitHub](https://github.com/highweb/drupal-bricks) and/or [sharing on Twitter](https://twitter.com/highwebtech/status/841004866633842689).
23 |
24 |
25 | ## Requirements
26 |
27 | All new Bricks for D8 has no requirements and works with ANY entity types!
28 |
29 |
30 | ## Compatibility
31 |
32 | | Drupal | Bricks | Layout API | [ECK](https://www.drupal.org/project/eck) | [IEF](https://www.drupal.org/project/inline_entity_form) | [ERR](https://www.drupal.org/project/entity_reference_revisions) | [Paragraphs](https://www.drupal.org/project/paragraphs) |
33 | | --- | --- | --- | --- | --- | --- | --- |
34 | | 8.3.3 | 1.6 | ✔ | 1.0-alpha3 | 1.0-beta1 | 1.3 | 1.1 |
35 | | 8.3.2 | 1.5 | — | 1.0-alpha3 | 1.0-beta1 | 1.3 | 1.1 |
36 | | 8.2.6 | 1.2 | — | 1.0-alpha3 | 1.0-beta1 | — | — |
37 |
38 | ### Upgrading from 8.x-1.5
39 |
40 | 1. Upgrade as usual.
41 | 2. Create **Layout** bundle manually to be able to use the newest Layout API integration:
42 | - ECK: Structure > ECK > Bundle list > Add bundle.
43 | - Paragraphs: Structure > Paragraphs > Add type.
44 | 3. Don't forget to allow this bundle in your Bricks field settings!
45 |
46 |
47 | ## Resources
48 |
49 | - Home page: https://uibricks.com
50 | - Project page: https://www.drupal.org/project/bricks
51 | - Source code: https://github.com/highweb/drupal-bricks
52 | - Issue board: https://contribkanban.com/board/bricks
53 | - Working group: https://groups.drupal.org/bricks
54 | - Team: http://timezone.io/team/drupal-bricks
55 |
--------------------------------------------------------------------------------
/bricks.info.yml:
--------------------------------------------------------------------------------
1 | name: Bricks
2 | description: Allows to create bricky content.
3 | package: Bricks
4 |
5 | type: module
6 | core: 8.x
7 |
8 | simplytest_dependencies:
9 | - bootstrap_kit
10 |
--------------------------------------------------------------------------------
/bricks.libraries.yml:
--------------------------------------------------------------------------------
1 | tabledrag.relationship-all:
2 | js:
3 | js/tabledrag.relationship-all.js: {}
4 |
--------------------------------------------------------------------------------
/bricks.module:
--------------------------------------------------------------------------------
1 | setLabel(t('Depth'));
20 |
21 | $properties['options'] = DataDefinition::create('any')
22 | ->setLabel(t('Options'));
23 | }
24 |
25 | /**
26 | * Helper function for FieldItemInterface::schema().
27 | */
28 | function _bricks_field_schema_alter(&$schema) {
29 | $schema['columns']['depth'] = [
30 | 'type' => 'int',
31 | 'size' => 'tiny',
32 | 'unsigned' => TRUE,
33 | ];
34 |
35 | $schema['columns']['options'] = [
36 | 'type' => 'blob',
37 | 'size' => 'normal',
38 | 'not null' => FALSE,
39 | 'serialize' => TRUE,
40 | ];
41 | }
42 |
43 | /* BRICKS FORMATTING */
44 |
45 | /**
46 | * Prepares variables for `field.html.twig`.
47 | */
48 | function bricks_preprocess_field(&$variables) {
49 | $element = $variables['element'];
50 |
51 | if (in_array($element['#formatter'], ['bricks_nested', 'bricks_nested_dynamic'])) {
52 | $variables['items'] = [
53 | [
54 | 'content' => _bricks_nest_items($element, $variables['items']),
55 | ],
56 | ];
57 | }
58 | }
59 |
60 | /**
61 | * Helper function: converts element's items to a tree structure.
62 | */
63 | function _bricks_nest_items($element, $items) {
64 |
65 | // Prepare items:
66 | $parents = [-1];
67 | $prev_depth = 0;
68 | foreach ($items as $delta => $item) {
69 | $depth = $element['#items'][$delta]->depth;
70 | if ($depth > $prev_depth) {
71 | array_unshift($parents, $delta - 1);
72 | }
73 | elseif ($depth < $prev_depth) {
74 | array_splice($parents, 0, $prev_depth - $depth);
75 | }
76 | $prev_depth = $depth;
77 |
78 | $items[$delta] = $items[$delta]['content'];
79 | $items[$delta]['#label'] = $element['#items'][$delta]->entity->label();
80 | $items[$delta]['#delta'] = $delta;
81 | $items[$delta]['#parent_delta'] = $parents[0];
82 | $items[$delta]['#attributes']['class'][] = 'brick';
83 | $items[$delta]['#attributes']['class'][] = 'brick--type--' . Html::cleanCssIdentifier($element['#items'][$delta]->entity->bundle());
84 | $items[$delta]['#attributes']['class'][] = 'brick--id--' . $element['#items'][$delta]->entity->id();
85 |
86 | $items[$delta]['childs'] = [];
87 | if (!empty($element['#items'][$delta]->options['view_mode'])) {
88 | $items[$delta]['#view_mode'] = $element['#items'][$delta]->options['view_mode'];
89 | }
90 | if (!empty($element['#items'][$delta]->options['layout'])) {
91 | $items[$delta]['#layout'] = $element['#items'][$delta]->options['layout'];
92 | }
93 | if (!empty($element['#items'][$delta]->options['css_class'])) {
94 | $items[$delta]['#attributes']['class'][] = $element['#items'][$delta]->options['css_class'];
95 | }
96 |
97 | // Disable entity render cache, rely on field cache:
98 | $items[$delta]['#cache'] = ['disabled' => TRUE];
99 | }
100 |
101 | // Process items in reverse order (without recursion):
102 | $rdeltas = array_reverse(array_keys($items));
103 | foreach ($rdeltas as $delta) {
104 | $parent_delta = $items[$delta]['#parent_delta'];
105 |
106 | if (!empty($items[$delta]['#layout']) && \Drupal::service('module_handler')->moduleExists('layout_discovery')) {
107 | $items[$delta] = array_intersect_key($items[$delta], array_flip(['#label', '#attributes'])) +
108 | _bricks_build_layout_from_items($items[$delta]['#layout'], $items[$delta]['childs']);
109 | }
110 |
111 | if ($parent_delta != -1) {
112 | array_unshift($items[$parent_delta]['childs'], $items[$delta]);
113 | unset($items[$delta]);
114 | }
115 | }
116 |
117 | return $items;
118 | }
119 |
120 | /**
121 | * Helper function for layout handling in _bricks_nest_items().
122 | */
123 | function _bricks_build_layout_from_items($layout, $items) {
124 | $layoutPluginManager = \Drupal::service('plugin.manager.core.layout');
125 | if (!$layoutPluginManager->hasDefinition($layout)) {
126 | drupal_set_message(t('Layout `%layout_id` is unknown.', ['%layout_id' => $layout]), 'warning');
127 | return;
128 | }
129 |
130 | // Provide any configuration to the layout plugin if necessary.
131 | $layoutInstance = $layoutPluginManager->createInstance($layout);
132 | $regionNames = $layoutInstance->getPluginDefinition()->getRegionNames();
133 |
134 | // Adjust the lengths:
135 | $count = min(count($regionNames), count($items));
136 | $regionNames = array_slice($regionNames, 0, $count);
137 | $items = array_slice($items, 0, $count);
138 |
139 | // Build the content for your regions.
140 | $regions = array_combine($regionNames, $items);
141 |
142 | // This builds the render array.
143 | return $layoutInstance->build($regions);
144 | }
145 |
146 | /* BRICKS EDITING */
147 |
148 | /**
149 | * Implements hook_field_widget_info_alter().
150 | */
151 | function bricks_field_widget_info_alter(array &$info) {
152 | // Let Bricks to re-use ANY Entity Reference -compatible widgets:
153 | foreach ($info as $widget_id => &$widget_info) {
154 | if (in_array('entity_reference', $widget_info['field_types'])) {
155 | $widget_info['field_types'][] = 'bricks';
156 | }
157 | if (in_array('entity_reference_revisions', $widget_info['field_types'])) {
158 | $widget_info['field_types'][] = 'bricks_revisioned';
159 | }
160 | }
161 | }
162 |
163 | /**
164 | * Implements hook_field_widget_WIDGET_TYPE_form_alter() for `entity_reference_autocomplete`.
165 | */
166 | function bricks_field_widget_entity_reference_autocomplete_form_alter(&$element, \Drupal\Core\Form\FormStateInterface $form_state, $context) {
167 | $field_type = $context['items']->getFieldDefinition()->getType();
168 |
169 | // @TODO: Replace by 'Nested bricks' widget setting.
170 | if (in_array($field_type, ['bricks'])) {
171 | // @TODO: Find a better way to be used in _bricks_preprocess_tabledrag_form().
172 | $element['#widget'] = 'entity_reference_autocomplete';
173 | // #default_value is en Entity or NULL.
174 | _bricks_form_element_alter($element, $context['items'][$context['delta']], $element['target_id']['#default_value']);
175 | hide($element['depth']);
176 | }
177 | }
178 | /**
179 | * Implements hook_field_widget_WIDGET_TYPE_form_alter() for `bricks_tree_autocomplete`.
180 | */
181 | function bricks_field_widget_bricks_tree_autocomplete_form_alter(&$element, \Drupal\Core\Form\FormStateInterface $form_state, $context) {
182 | bricks_field_widget_entity_reference_autocomplete_form_alter($element, $form_state, $context);
183 | }
184 |
185 | /**
186 | * Implements hook_field_widget_WIDGET_TYPE_form_alter() for `paragraphs`.
187 | */
188 | function bricks_field_widget_paragraphs_form_alter(&$element, \Drupal\Core\Form\FormStateInterface $form_state, $context) {
189 | $field_type = $context['items']->getFieldDefinition()->getType();
190 |
191 | // @TODO: Replace by 'Nested bricks' widget setting.
192 | if (in_array($field_type, ['bricks_revisioned'])) {
193 | // @TODO: Find a better way to be used in _bricks_preprocess_tabledrag_form().
194 | $element['#widget'] = 'paragraphs';
195 | $item = $context['items'][$context['delta']];
196 | $entity = $item->target_id ? entity_load('paragraph', $item->target_id) : entity_create('paragraph', array('type' => $element['subform']['#process'][0][0]->getTargetBundle()));
197 | _bricks_form_element_alter($element, $item, $entity);
198 | hide($element['depth']);
199 | }
200 | }
201 |
202 | /**
203 | * Prepares variables for `field-multiple-value-form.html.twig`.
204 | */
205 | function bricks_preprocess_field_multiple_value_form(&$variables) {
206 | _bricks_preprocess_tabledrag_form($variables, 'element', 'entity_reference_autocomplete', $variables['element']['#field_name'] . '-delta-order');
207 | _bricks_preprocess_tabledrag_form($variables, 'element', 'paragraphs', $variables['element']['#field_name'] . '-delta-order');
208 | }
209 |
210 | /**
211 | * Helper function for hook_preprocess_field_multiple_value_form().
212 | */
213 | function _bricks_preprocess_tabledrag_form(&$variables, $element_key, $widget, $order_class, $render_options = FALSE) {
214 | $element = $variables[$element_key];
215 |
216 | // @TODO: Replace by 'Nested bricks' widget setting.
217 | if (isset($element['#widget']) && $element['#widget'] == $widget ||
218 | isset($element[0]['#widget']) && $element[0]['#widget'] == $widget) {
219 | // @TODO: Tmp hack for the proper indent width calculation.
220 | $variables['table']['#header'][0]['style'] = 'min-width: 150px';
221 | $variables['table']['#header'][] = ['data' => t('Depth'), 'class' => ['bricks-depth-header']];
222 |
223 | $row = 0;
224 | foreach (Element::children($element) as $i => $key) {
225 | if ($key !== 'add_more' && $key !== 'header_actions') {
226 | $depth = $element[$key]['depth']['#value'];
227 |
228 | $indentation = [];
229 | if ($depth > 0) {
230 | $indentation = [
231 | '#theme' => 'indentation',
232 | '#size' => $depth,
233 | ];
234 | }
235 |
236 | $drag_cell = &$variables['table']['#rows'][$row]['data'][0];
237 | $drag_cell['data'] = !empty($indentation) ? drupal_render($indentation) : '' . $drag_cell['data'];
238 | // @TODO
239 | $drag_cell['style'] = 'width: auto; min-width: 150px';
240 |
241 | show($element[$key]['depth']);
242 | $variables['table']['#rows'][$row]['data'][] = \Drupal::service('renderer')->render($element[$key]['depth']);
243 |
244 | // @TODO: Get rid of $render_options hack.
245 | if ($render_options) {
246 | $element[$key]['options']['#prefix'] = $variables['table']['#rows'][$row]['data'][2]['data'];
247 | $variables['table']['#rows'][$row]['data'][2]['data'] = \Drupal::service('renderer')->render($element[$key]['options']);
248 | }
249 |
250 | }
251 | if ($key !== 'add_more') {
252 | $row++;
253 | }
254 | }
255 |
256 | $tabledrag_options = &$variables['table']['#tabledrag'];
257 | $tabledrag_options[0]['relationship'] = 'all';
258 | $tabledrag_options[] = [
259 | 'action' => 'depth',
260 | 'relationship' => 'group',
261 | 'group' => 'bricks-depth',
262 | ];
263 | // Fake option to enable indentation:
264 | $tabledrag_options[] = [
265 | 'action' => 'match',
266 | 'relationship' => 'parent',
267 | 'group' => $order_class,
268 | ];
269 |
270 | $variables['table']['#attached']['library'][] = 'bricks/tabledrag.relationship-all';
271 | }
272 | }
273 |
274 | /**
275 | * Helper function for widget's formElement().
276 | */
277 | function _bricks_form_element_alter(&$element, $item, $entity) {
278 | $element['depth'] = [
279 | // @TODO: Other types break the correct indentations.
280 | '#type' => 'hidden',
281 | '#default_value' => !empty($item->depth) ? $item->depth : 0,
282 | '#weight' => 10,
283 | '#attributes' => [
284 | 'class' => ['bricks-depth'],
285 | ],
286 | ];
287 | $element['options'] = [
288 | '#type' => 'container',
289 | '#weight' => 100,
290 | '#attributes' => [
291 | 'class' => ['container-inline'],
292 | ],
293 | ];
294 | if ($entity) {
295 | if ($entity->bundle() == 'layout' && \Drupal::service('module_handler')->moduleExists('layout_discovery')) {
296 | $element['options']['layout'] = [
297 | '#type' => 'select',
298 | '#options' => \Drupal::service('plugin.manager.core.layout')->getLayoutOptions(),
299 | '#default_value' => !empty($item->options['layout']) ? $item->options['layout'] : NULL,
300 | ];
301 | }
302 | if ($entity->bundle() != 'layout') {
303 | $element['options']['view_mode'] = [
304 | '#type' => 'select',
305 | '#options' => \Drupal::service('entity_display.repository')->getViewModeOptionsByBundle($entity->getEntityTypeId(), $entity->bundle()),
306 | '#default_value' => !empty($item->options['view_mode']) ? $item->options['view_mode'] : NULL,
307 | ];
308 | }
309 | }
310 | $element['options']['css_class'] = [
311 | '#type' => 'textfield',
312 | '#default_value' => !empty($item->options['css_class']) ? $item->options['css_class'] : '',
313 | '#size' => 10,
314 | '#attributes' => [
315 | 'placeholder' => t('CSS class(-es)'),
316 | ],
317 | ];
318 | }
319 |
320 | /* MISC */
321 |
322 | /**
323 | * Prepares variables for `block.html.twig` for `system_powered_by_block`.
324 | */
325 | function bricks_preprocess_block__system_powered_by_block(&$variables) {
326 | $bricks_link = 'Bricks';
327 | $variables['content']['#markup'] = str_replace('>Drupal', '>Drupal & ' . $bricks_link, $variables['content']['#markup']);
328 | }
329 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "drupal/bricks",
3 | "type": "drupal-module",
4 | "description": "Allows to create bricky content.",
5 | "keywords": ["Drupal"],
6 | "license": "GPL-2.0+",
7 | "homepage": "https://www.drupal.org/project/bricks",
8 | "minimum-stability": "dev",
9 | "support": {
10 | "issues": "https://www.drupal.org/project/issues/bricks",
11 | "source": "https://github.com/highweb/drupal-bricks"
12 | },
13 | "require": { }
14 | }
15 |
--------------------------------------------------------------------------------
/js/tabledrag.relationship-all.js:
--------------------------------------------------------------------------------
1 | (function ($, Drupal) {
2 |
3 | var findSiblings = Drupal.tableDrag.prototype.row.prototype.findSiblings;
4 | Drupal.tableDrag.prototype.row.prototype.findSiblings = function (rowSettings) {
5 | if (rowSettings.relationship === 'all') {
6 | var siblings = [];
7 | var directions = ['prev', 'next'];
8 | var rowIndentation = this.indents;
9 | for (var d = 0; d < directions.length; d++) {
10 | var checkRow = $(this.element)[directions[d]]();
11 | while (checkRow.length) {
12 | // Check that the sibling contains a similar target field.
13 | if ($('.' + rowSettings.target, checkRow)) {
14 | siblings.push(checkRow[0]);
15 | }
16 | else {
17 | break;
18 | }
19 | checkRow = $(checkRow)[directions[d]]();
20 | }
21 | // Since siblings are added in reverse order for previous, reverse the
22 | // completed list of previous siblings. Add the current row and continue.
23 | if (directions[d] == 'prev') {
24 | siblings.reverse();
25 | siblings.push(this.element);
26 | }
27 | }
28 | return siblings;
29 | }
30 | else {
31 | return findSiblings.apply(this, arguments);
32 | }
33 | };
34 |
35 | })(jQuery, Drupal);
36 |
--------------------------------------------------------------------------------
/modules/bricks_default/bricks_default.info.yml:
--------------------------------------------------------------------------------
1 | name: 'Bricks Default'
2 | description: 'Dummy module for backward-compatibility.'
3 | package: Bricks
4 | type: module
5 | core: 8.x
6 |
--------------------------------------------------------------------------------
/modules/bricks_default_blocks/bricks_default_blocks.features.yml:
--------------------------------------------------------------------------------
1 | excluded:
2 | - core.base_field_override.node.bricky_blocks.promote
3 | - block_content.type.basic
4 | - core.entity_form_display.block_content.basic.default
5 | - core.entity_view_display.block_content.basic.default
6 | - field.field.block_content.basic.body
7 | required: true
8 |
--------------------------------------------------------------------------------
/modules/bricks_default_blocks/bricks_default_blocks.info.yml:
--------------------------------------------------------------------------------
1 | name: 'Bricks Default Blocks'
2 | description: 'Defaut setup for Bricks + Custom Block.'
3 | package: Bricks
4 | type: module
5 | core: 8.x
6 | dependencies:
7 | - block_content
8 | - bricks
9 | - bricks_inline
10 | - field
11 | - file
12 | - image
13 | - layout_discovery
14 | - menu_ui
15 | - node
16 | - path
17 | - text
18 | - user
19 |
--------------------------------------------------------------------------------
/modules/bricks_default_blocks/bricks_default_blocks.install:
--------------------------------------------------------------------------------
1 | getStorage('block_content')->create([
15 | 'type' => 'layout',
16 | 'info' => 'Layout',
17 | ]);
18 | $layout->save();
19 |
20 | $data = file_get_contents(drupal_get_path('theme', 'bartik') . '/screenshot.png');
21 | $file = file_save_data($data, 'public://bartik.png');
22 | $image = $entity_manager->getStorage('block_content')->create([
23 | 'type' => 'image',
24 | 'info' => 'Image',
25 | 'field_image' => [
26 | 'target_id' => $file->id(),
27 | ],
28 | ]);
29 | $image->save();
30 |
31 | $text = $entity_manager->getStorage('block_content')->create([
32 | 'type' => 'basic',
33 | 'info' => 'Text',
34 | 'body' => [
35 | 'value' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
36 | 'format' => 'basic_html',
37 | ],
38 | ]);
39 | $text->save();
40 |
41 | $wrapper = $entity_manager->getStorage('block_content')->create([
42 | 'type' => 'wrapper',
43 | 'info' => 'Wrapper',
44 | ]);
45 | $wrapper->save();
46 |
47 | $page = $entity_manager->getStorage('node')->create([
48 | 'type' => 'bricky_blocks',
49 | 'title' => 'Bricks + Blocks = ♥',
50 | 'field_body_blocks' => [
51 | ['depth' => 0, 'target_id' => $layout->id(), 'options' => ['layout' => 'layout_twocol']],
52 | ['depth' => 1, 'target_id' => $text->id()],
53 | ['depth' => 1, 'target_id' => $image->id()],
54 | ['depth' => 1, 'target_id' => $text->id(), 'options' => ['css_class' => 'text-align-right']],
55 | ['depth' => 1, 'target_id' => $text->id()],
56 | ],
57 | ]);
58 | $page->save();
59 | }
60 |
--------------------------------------------------------------------------------
/modules/bricks_default_blocks/config/install/block_content.type.image.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies: { }
4 | id: image
5 | label: Image
6 | revision: 0
7 | description: 'Basic image entity.'
8 |
--------------------------------------------------------------------------------
/modules/bricks_default_blocks/config/install/block_content.type.layout.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies: { }
4 | id: layout
5 | label: Layout
6 | revision: 0
7 | description: 'Special bundle to use Layout API in Bricks.'
8 |
--------------------------------------------------------------------------------
/modules/bricks_default_blocks/config/install/block_content.type.wrapper.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies: { }
4 | id: wrapper
5 | label: Wrapper
6 | revision: 0
7 | description: 'Special entity for wrapping or grouping other entities.'
8 |
--------------------------------------------------------------------------------
/modules/bricks_default_blocks/config/install/core.entity_form_display.block_content.image.default.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | config:
5 | - block_content.type.image
6 | - field.field.block_content.image.field_image
7 | - image.style.thumbnail
8 | module:
9 | - image
10 | id: block_content.image.default
11 | targetEntityType: block_content
12 | bundle: image
13 | mode: default
14 | content:
15 | field_image:
16 | weight: 26
17 | settings:
18 | progress_indicator: throbber
19 | preview_image_style: thumbnail
20 | third_party_settings: { }
21 | type: image_image
22 | region: content
23 | info:
24 | type: string_textfield
25 | weight: -5
26 | region: content
27 | settings:
28 | size: 60
29 | placeholder: ''
30 | third_party_settings: { }
31 | hidden: { }
32 |
--------------------------------------------------------------------------------
/modules/bricks_default_blocks/config/install/core.entity_form_display.block_content.layout.default.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | config:
5 | - block_content.type.layout
6 | id: block_content.layout.default
7 | targetEntityType: block_content
8 | bundle: layout
9 | mode: default
10 | content:
11 | info:
12 | type: string_textfield
13 | weight: -5
14 | region: content
15 | settings:
16 | size: 60
17 | placeholder: ''
18 | third_party_settings: { }
19 | hidden: { }
20 |
--------------------------------------------------------------------------------
/modules/bricks_default_blocks/config/install/core.entity_form_display.block_content.wrapper.default.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | config:
5 | - block_content.type.wrapper
6 | id: block_content.wrapper.default
7 | targetEntityType: block_content
8 | bundle: wrapper
9 | mode: default
10 | content:
11 | info:
12 | type: string_textfield
13 | weight: -5
14 | region: content
15 | settings:
16 | size: 60
17 | placeholder: ''
18 | third_party_settings: { }
19 | hidden: { }
20 |
--------------------------------------------------------------------------------
/modules/bricks_default_blocks/config/install/core.entity_form_display.node.bricky_blocks.default.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | config:
5 | - field.field.node.bricky_blocks.field_body_blocks
6 | - node.type.bricky_blocks
7 | module:
8 | - bricks_inline
9 | - path
10 | id: node.bricky_blocks.default
11 | targetEntityType: node
12 | bundle: bricky_blocks
13 | mode: default
14 | content:
15 | created:
16 | type: datetime_timestamp
17 | weight: 3
18 | region: content
19 | settings: { }
20 | third_party_settings: { }
21 | field_body_blocks:
22 | weight: 1
23 | settings:
24 | form_mode: default
25 | label_singular: ''
26 | label_plural: ''
27 | allow_new: '1'
28 | allow_existing: '1'
29 | match_operator: CONTAINS
30 | override_labels: 0
31 | third_party_settings: { }
32 | type: bricks_tree_inline
33 | region: content
34 | path:
35 | type: path
36 | weight: 6
37 | region: content
38 | settings: { }
39 | third_party_settings: { }
40 | promote:
41 | type: boolean_checkbox
42 | settings:
43 | display_label: true
44 | weight: 4
45 | region: content
46 | third_party_settings: { }
47 | sticky:
48 | type: boolean_checkbox
49 | settings:
50 | display_label: true
51 | weight: 5
52 | region: content
53 | third_party_settings: { }
54 | title:
55 | type: string_textfield
56 | weight: 0
57 | region: content
58 | settings:
59 | size: 60
60 | placeholder: ''
61 | third_party_settings: { }
62 | uid:
63 | type: entity_reference_autocomplete
64 | weight: 2
65 | settings:
66 | match_operator: CONTAINS
67 | size: 60
68 | placeholder: ''
69 | region: content
70 | third_party_settings: { }
71 | hidden: { }
72 |
--------------------------------------------------------------------------------
/modules/bricks_default_blocks/config/install/core.entity_view_display.block_content.image.default.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | config:
5 | - block_content.type.image
6 | - field.field.block_content.image.field_image
7 | module:
8 | - image
9 | id: block_content.image.default
10 | targetEntityType: block_content
11 | bundle: image
12 | mode: default
13 | content:
14 | field_image:
15 | weight: 0
16 | label: hidden
17 | settings:
18 | image_style: ''
19 | image_link: ''
20 | third_party_settings: { }
21 | type: image
22 | region: content
23 | hidden: { }
24 |
--------------------------------------------------------------------------------
/modules/bricks_default_blocks/config/install/core.entity_view_display.block_content.layout.default.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | config:
5 | - block_content.type.layout
6 | id: block_content.layout.default
7 | targetEntityType: block_content
8 | bundle: layout
9 | mode: default
10 | content: { }
11 | hidden: { }
12 |
--------------------------------------------------------------------------------
/modules/bricks_default_blocks/config/install/core.entity_view_display.node.bricky_blocks.default.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | config:
5 | - field.field.node.bricky_blocks.field_body_blocks
6 | - node.type.bricky_blocks
7 | module:
8 | - bricks
9 | - user
10 | id: node.bricky_blocks.default
11 | targetEntityType: node
12 | bundle: bricky_blocks
13 | mode: default
14 | content:
15 | field_body_blocks:
16 | weight: 0
17 | label: hidden
18 | settings:
19 | view_mode: default
20 | link: false
21 | third_party_settings: { }
22 | type: bricks_nested
23 | region: content
24 | links:
25 | weight: 1
26 | region: content
27 | settings: { }
28 | third_party_settings: { }
29 | hidden: { }
30 |
--------------------------------------------------------------------------------
/modules/bricks_default_blocks/config/install/core.entity_view_display.node.bricky_blocks.teaser.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | config:
5 | - core.entity_view_mode.node.teaser
6 | - field.field.node.bricky_blocks.field_body_blocks
7 | - node.type.bricky_blocks
8 | module:
9 | - bricks
10 | - user
11 | id: node.bricky_blocks.teaser
12 | targetEntityType: node
13 | bundle: bricky_blocks
14 | mode: teaser
15 | content:
16 | field_body_blocks:
17 | type: bricks_nested
18 | weight: 0
19 | region: content
20 | label: hidden
21 | settings:
22 | view_mode: default
23 | link: false
24 | third_party_settings: { }
25 | links:
26 | weight: 1
27 | region: content
28 | settings: { }
29 | third_party_settings: { }
30 | hidden: { }
31 |
--------------------------------------------------------------------------------
/modules/bricks_default_blocks/config/install/field.field.block_content.image.field_image.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | config:
5 | - block_content.type.image
6 | - field.storage.block_content.field_image
7 | module:
8 | - image
9 | id: block_content.image.field_image
10 | field_name: field_image
11 | entity_type: block_content
12 | bundle: image
13 | label: Image
14 | description: ''
15 | required: false
16 | translatable: false
17 | default_value: { }
18 | default_value_callback: ''
19 | settings:
20 | file_directory: '[date:custom:Y]-[date:custom:m]'
21 | file_extensions: 'png gif jpg jpeg'
22 | max_filesize: ''
23 | max_resolution: ''
24 | min_resolution: ''
25 | alt_field: true
26 | alt_field_required: false
27 | title_field: false
28 | title_field_required: false
29 | default_image:
30 | uuid: ''
31 | alt: ''
32 | title: ''
33 | width: null
34 | height: null
35 | handler: 'default:file'
36 | handler_settings: { }
37 | field_type: image
38 |
--------------------------------------------------------------------------------
/modules/bricks_default_blocks/config/install/field.field.node.bricky_blocks.field_body_blocks.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | config:
5 | - block_content.type.basic
6 | - block_content.type.image
7 | - block_content.type.layout
8 | - field.storage.node.field_body_blocks
9 | - node.type.bricky_blocks
10 | module:
11 | - bricks
12 | id: node.bricky_blocks.field_body_blocks
13 | field_name: field_body_blocks
14 | entity_type: node
15 | bundle: bricky_blocks
16 | label: Body
17 | description: ''
18 | required: false
19 | translatable: false
20 | default_value: { }
21 | default_value_callback: ''
22 | settings:
23 | handler: 'default:block_content'
24 | handler_settings:
25 | target_bundles:
26 | basic: basic
27 | image: image
28 | layout: layout
29 | sort:
30 | field: _none
31 | auto_create: 0
32 | auto_create_bundle: basic
33 | field_type: bricks
34 |
--------------------------------------------------------------------------------
/modules/bricks_default_blocks/config/install/field.storage.block_content.field_image.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | module:
5 | - block_content
6 | - file
7 | - image
8 | id: block_content.field_image
9 | field_name: field_image
10 | entity_type: block_content
11 | type: image
12 | settings:
13 | uri_scheme: public
14 | default_image:
15 | uuid: ''
16 | alt: ''
17 | title: ''
18 | width: null
19 | height: null
20 | target_type: file
21 | display_field: false
22 | display_default: false
23 | module: image
24 | locked: false
25 | cardinality: 1
26 | translatable: true
27 | indexes: { }
28 | persist_with_no_fields: false
29 | custom_storage: false
30 |
--------------------------------------------------------------------------------
/modules/bricks_default_blocks/config/install/field.storage.node.field_body_blocks.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | module:
5 | - block_content
6 | - bricks
7 | - node
8 | id: node.field_body_blocks
9 | field_name: field_body_blocks
10 | entity_type: node
11 | type: bricks
12 | settings:
13 | target_type: block_content
14 | module: bricks
15 | locked: false
16 | cardinality: -1
17 | translatable: true
18 | indexes: { }
19 | persist_with_no_fields: false
20 | custom_storage: false
21 |
--------------------------------------------------------------------------------
/modules/bricks_default_blocks/config/install/node.type.bricky_blocks.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | module:
5 | - menu_ui
6 | third_party_settings:
7 | menu_ui:
8 | available_menus:
9 | - main
10 | parent: 'main:'
11 | name: 'Bricky blocks'
12 | type: bricky_blocks
13 | description: 'Use bricky pages for your flexible content, such as ''Home'' or ''Company'' pages.'
14 | help: ''
15 | new_revision: true
16 | preview_mode: 1
17 | display_submitted: false
18 |
--------------------------------------------------------------------------------
/modules/bricks_default_eck/bricks_default_eck.features.yml:
--------------------------------------------------------------------------------
1 | excluded:
2 | - node.type.page
3 | - rdf.mapping.node.page
4 | - core.base_field_override.node.page.promote
5 | - core.base_field_override.node.bricky_eck.promote
6 | required: true
7 |
--------------------------------------------------------------------------------
/modules/bricks_default_eck/bricks_default_eck.info.yml:
--------------------------------------------------------------------------------
1 | name: 'Bricks Default ECK'
2 | description: 'Defaut setup for Bricks + ECK.'
3 | package: Bricks
4 | type: module
5 | core: 8.x
6 | dependencies:
7 | - bricks
8 | - bricks_inline
9 | - eck
10 | - field
11 | - file
12 | - image
13 | - inline_entity_form
14 | - layout_discovery
15 | - menu_ui
16 | - node
17 | - path
18 | - text
19 | - user
20 |
--------------------------------------------------------------------------------
/modules/bricks_default_eck/bricks_default_eck.install:
--------------------------------------------------------------------------------
1 | getStorage('basic')->create([
15 | 'type' => 'layout',
16 | 'title' => 'Layout',
17 | ]);
18 | $layout->save();
19 |
20 | $data = file_get_contents(drupal_get_path('theme', 'bartik') . '/screenshot.png');
21 | $file = file_save_data($data, 'public://bartik.png');
22 | $image = $entity_manager->getStorage('basic')->create([
23 | 'type' => 'image',
24 | 'title' => 'Image',
25 | 'field_image' => [
26 | 'target_id' => $file->id(),
27 | ],
28 | ]);
29 | $image->save();
30 |
31 | $text = $entity_manager->getStorage('basic')->create([
32 | 'type' => 'text',
33 | 'title' => 'Text',
34 | 'field_text' => [
35 | 'value' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
36 | 'format' => 'plain_text',
37 | ],
38 | ]);
39 | $text->save();
40 |
41 | $wrapper = $entity_manager->getStorage('basic')->create([
42 | 'type' => 'wrapper',
43 | 'title' => 'Wrapper',
44 | ]);
45 | $wrapper->save();
46 |
47 | $page = $entity_manager->getStorage('node')->create([
48 | 'type' => 'bricky_eck',
49 | 'title' => 'Bricks + ECK = ♥',
50 | 'field_body_eck' => [
51 | ['depth' => 0, 'target_id' => $layout->id(), 'options' => ['layout' => 'layout_twocol']],
52 | ['depth' => 1, 'target_id' => $text->id()],
53 | ['depth' => 1, 'target_id' => $image->id()],
54 | ['depth' => 1, 'target_id' => $text->id(), 'options' => ['css_class' => 'text-align-right']],
55 | ['depth' => 1, 'target_id' => $text->id()],
56 | ],
57 | ]);
58 | $page->save();
59 | }
60 |
--------------------------------------------------------------------------------
/modules/bricks_default_eck/config/install/core.entity_form_display.basic.image.default.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | config:
5 | - eck.eck_type.basic.image
6 | - field.field.basic.image.field_image
7 | - image.style.thumbnail
8 | module:
9 | - image
10 | id: basic.image.default
11 | targetEntityType: basic
12 | bundle: image
13 | mode: default
14 | content:
15 | field_image:
16 | weight: 3
17 | settings:
18 | progress_indicator: throbber
19 | preview_image_style: thumbnail
20 | third_party_settings: { }
21 | type: image_image
22 | region: content
23 | title:
24 | type: string_textfield
25 | weight: -5
26 | settings:
27 | size: 60
28 | placeholder: ''
29 | third_party_settings: { }
30 | region: content
31 | hidden: { }
32 |
--------------------------------------------------------------------------------
/modules/bricks_default_eck/config/install/core.entity_form_display.basic.text.default.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | config:
5 | - eck.eck_type.basic.text
6 | - field.field.basic.text.field_text
7 | module:
8 | - text
9 | id: basic.text.default
10 | targetEntityType: basic
11 | bundle: text
12 | mode: default
13 | content:
14 | field_text:
15 | weight: 3
16 | settings:
17 | rows: 5
18 | placeholder: ''
19 | third_party_settings: { }
20 | type: text_textarea
21 | region: content
22 | title:
23 | type: string_textfield
24 | weight: -5
25 | settings:
26 | size: 60
27 | placeholder: ''
28 | third_party_settings: { }
29 | region: content
30 | hidden: { }
31 |
--------------------------------------------------------------------------------
/modules/bricks_default_eck/config/install/core.entity_form_display.node.bricky_eck.default.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | config:
5 | - field.field.node.bricky_eck.field_body_eck
6 | - node.type.bricky_eck
7 | module:
8 | - bricks_inline
9 | - path
10 | id: node.bricky_eck.default
11 | targetEntityType: node
12 | bundle: bricky_eck
13 | mode: default
14 | content:
15 | created:
16 | type: datetime_timestamp
17 | weight: 3
18 | settings: { }
19 | third_party_settings: { }
20 | region: content
21 | field_body_eck:
22 | weight: 1
23 | settings:
24 | form_mode: default
25 | label_singular: ''
26 | label_plural: ''
27 | allow_new: '1'
28 | allow_existing: '1'
29 | match_operator: CONTAINS
30 | override_labels: 0
31 | third_party_settings: { }
32 | type: bricks_tree_inline
33 | region: content
34 | path:
35 | type: path
36 | weight: 6
37 | settings: { }
38 | third_party_settings: { }
39 | region: content
40 | promote:
41 | type: boolean_checkbox
42 | settings:
43 | display_label: true
44 | weight: 4
45 | third_party_settings: { }
46 | region: content
47 | sticky:
48 | type: boolean_checkbox
49 | settings:
50 | display_label: true
51 | weight: 5
52 | third_party_settings: { }
53 | region: content
54 | title:
55 | type: string_textfield
56 | weight: 0
57 | settings:
58 | size: 60
59 | placeholder: ''
60 | third_party_settings: { }
61 | region: content
62 | uid:
63 | type: entity_reference_autocomplete
64 | weight: 2
65 | settings:
66 | match_operator: CONTAINS
67 | size: 60
68 | placeholder: ''
69 | third_party_settings: { }
70 | region: content
71 | hidden: { }
72 |
--------------------------------------------------------------------------------
/modules/bricks_default_eck/config/install/core.entity_view_display.basic.image.default.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | config:
5 | - eck.eck_type.basic.image
6 | - field.field.basic.image.field_image
7 | module:
8 | - image
9 | id: basic.image.default
10 | targetEntityType: basic
11 | bundle: image
12 | mode: default
13 | content:
14 | field_image:
15 | weight: -4
16 | label: hidden
17 | settings:
18 | image_style: ''
19 | image_link: ''
20 | third_party_settings: { }
21 | type: image
22 | region: content
23 | hidden:
24 | title: true
25 |
--------------------------------------------------------------------------------
/modules/bricks_default_eck/config/install/core.entity_view_display.basic.text.default.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | config:
5 | - eck.eck_type.basic.text
6 | - field.field.basic.text.field_text
7 | module:
8 | - text
9 | id: basic.text.default
10 | targetEntityType: basic
11 | bundle: text
12 | mode: default
13 | content:
14 | field_text:
15 | weight: -4
16 | label: hidden
17 | settings: { }
18 | third_party_settings: { }
19 | type: text_default
20 | region: content
21 | hidden:
22 | title: true
23 |
--------------------------------------------------------------------------------
/modules/bricks_default_eck/config/install/core.entity_view_display.basic.wrapper.default.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | config:
5 | - eck.eck_type.basic.wrapper
6 | id: basic.wrapper.default
7 | targetEntityType: basic
8 | bundle: wrapper
9 | mode: default
10 | content: { }
11 | hidden:
12 | title: true
13 |
--------------------------------------------------------------------------------
/modules/bricks_default_eck/config/install/core.entity_view_display.node.bricky_eck.default.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | config:
5 | - field.field.node.bricky_eck.field_body_eck
6 | - node.type.bricky_eck
7 | module:
8 | - bricks
9 | - user
10 | id: node.bricky_eck.default
11 | targetEntityType: node
12 | bundle: bricky_eck
13 | mode: default
14 | content:
15 | field_body_eck:
16 | weight: -1
17 | label: hidden
18 | settings:
19 | view_mode: default
20 | link: false
21 | third_party_settings: { }
22 | type: bricks_nested
23 | region: content
24 | hidden:
25 | links: true
26 |
--------------------------------------------------------------------------------
/modules/bricks_default_eck/config/install/core.entity_view_display.node.bricky_eck.teaser.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | config:
5 | - core.entity_view_mode.node.teaser
6 | - field.field.node.bricky_eck.field_body_eck
7 | - node.type.bricky_eck
8 | module:
9 | - bricks
10 | - user
11 | id: node.bricky_eck.teaser
12 | targetEntityType: node
13 | bundle: bricky_eck
14 | mode: teaser
15 | content:
16 | field_body_eck:
17 | type: bricks_nested
18 | weight: 0
19 | label: hidden
20 | settings:
21 | view_mode: default
22 | link: false
23 | third_party_settings: { }
24 | region: content
25 | hidden:
26 | links: true
27 |
--------------------------------------------------------------------------------
/modules/bricks_default_eck/config/install/eck.eck_entity_type.basic.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies: { }
4 | id: basic
5 | label: Basic
6 | created: false
7 | changed: false
8 | uid: false
9 | title: true
10 |
--------------------------------------------------------------------------------
/modules/bricks_default_eck/config/install/eck.eck_type.basic.image.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | config:
5 | - eck.eck_entity_type.basic
6 | name: Image
7 | type: image
8 | description: 'Basic image entity.'
9 |
--------------------------------------------------------------------------------
/modules/bricks_default_eck/config/install/eck.eck_type.basic.layout.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | config:
5 | - eck.eck_entity_type.basic
6 | name: Layout
7 | type: layout
8 | description: 'Special bundle to use Layout API in Bricks.'
9 |
--------------------------------------------------------------------------------
/modules/bricks_default_eck/config/install/eck.eck_type.basic.text.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | config:
5 | - eck.eck_entity_type.basic
6 | name: Text
7 | type: text
8 | description: 'Basic text entity.'
9 |
--------------------------------------------------------------------------------
/modules/bricks_default_eck/config/install/eck.eck_type.basic.wrapper.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | config:
5 | - eck.eck_entity_type.basic
6 | name: Wrapper
7 | type: wrapper
8 | description: 'Special entity for wrapping or grouping other entities.'
9 |
--------------------------------------------------------------------------------
/modules/bricks_default_eck/config/install/field.field.basic.image.field_image.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | config:
5 | - eck.eck_type.basic.image
6 | - field.storage.basic.field_image
7 | module:
8 | - image
9 | id: basic.image.field_image
10 | field_name: field_image
11 | entity_type: basic
12 | bundle: image
13 | label: Image
14 | description: ''
15 | required: false
16 | translatable: false
17 | default_value: { }
18 | default_value_callback: ''
19 | settings:
20 | file_directory: '[date:custom:Y]-[date:custom:m]'
21 | file_extensions: 'png gif jpg jpeg'
22 | max_filesize: ''
23 | max_resolution: ''
24 | min_resolution: ''
25 | alt_field: true
26 | alt_field_required: false
27 | title_field: false
28 | title_field_required: false
29 | default_image:
30 | uuid: ''
31 | alt: ''
32 | title: ''
33 | width: null
34 | height: null
35 | handler: 'default:file'
36 | handler_settings: { }
37 | field_type: image
38 |
--------------------------------------------------------------------------------
/modules/bricks_default_eck/config/install/field.field.basic.text.field_text.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | config:
5 | - eck.eck_type.basic.text
6 | - field.storage.basic.field_text
7 | module:
8 | - text
9 | id: basic.text.field_text
10 | field_name: field_text
11 | entity_type: basic
12 | bundle: text
13 | label: Text
14 | description: ''
15 | required: false
16 | translatable: false
17 | default_value: { }
18 | default_value_callback: ''
19 | settings: { }
20 | field_type: text_long
21 |
--------------------------------------------------------------------------------
/modules/bricks_default_eck/config/install/field.field.node.bricky_eck.field_body_eck.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | config:
5 | - eck.eck_type.basic.image
6 | - eck.eck_type.basic.layout
7 | - eck.eck_type.basic.text
8 | - eck.eck_type.basic.wrapper
9 | - field.storage.node.field_body_eck
10 | - node.type.bricky_eck
11 | module:
12 | - bricks
13 | id: node.bricky_eck.field_body_eck
14 | field_name: field_body_eck
15 | entity_type: node
16 | bundle: bricky_eck
17 | label: Body
18 | description: ''
19 | required: false
20 | translatable: true
21 | default_value: { }
22 | default_value_callback: ''
23 | settings:
24 | handler: 'default:basic'
25 | handler_settings:
26 | target_bundles:
27 | image: image
28 | layout: layout
29 | text: text
30 | wrapper: wrapper
31 | sort:
32 | field: _none
33 | auto_create: 0
34 | auto_create_bundle: text
35 | field_type: bricks
36 |
--------------------------------------------------------------------------------
/modules/bricks_default_eck/config/install/field.storage.basic.field_image.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | module:
5 | - eck
6 | - file
7 | - image
8 | id: basic.field_image
9 | field_name: field_image
10 | entity_type: basic
11 | type: image
12 | settings:
13 | uri_scheme: public
14 | default_image:
15 | uuid: ''
16 | alt: ''
17 | title: ''
18 | width: null
19 | height: null
20 | target_type: file
21 | display_field: false
22 | display_default: false
23 | module: image
24 | locked: false
25 | cardinality: 1
26 | translatable: true
27 | indexes: { }
28 | persist_with_no_fields: false
29 | custom_storage: false
30 |
--------------------------------------------------------------------------------
/modules/bricks_default_eck/config/install/field.storage.basic.field_text.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | module:
5 | - eck
6 | - text
7 | id: basic.field_text
8 | field_name: field_text
9 | entity_type: basic
10 | type: text_long
11 | settings: { }
12 | module: text
13 | locked: false
14 | cardinality: 1
15 | translatable: true
16 | indexes: { }
17 | persist_with_no_fields: false
18 | custom_storage: false
19 |
--------------------------------------------------------------------------------
/modules/bricks_default_eck/config/install/field.storage.node.field_body_eck.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | module:
5 | - bricks
6 | - eck
7 | - node
8 | id: node.field_body_eck
9 | field_name: field_body_eck
10 | entity_type: node
11 | type: bricks
12 | settings:
13 | target_type: basic
14 | module: bricks
15 | locked: false
16 | cardinality: -1
17 | translatable: true
18 | indexes: { }
19 | persist_with_no_fields: false
20 | custom_storage: false
21 |
--------------------------------------------------------------------------------
/modules/bricks_default_eck/config/install/node.type.bricky_eck.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | module:
5 | - menu_ui
6 | third_party_settings:
7 | menu_ui:
8 | available_menus:
9 | - main
10 | parent: 'main:'
11 | name: 'Bricky ECK'
12 | type: bricky_eck
13 | description: 'Use bricky pages for your flexible content, such as ''Home'' or ''Company'' pages.'
14 | help: ''
15 | new_revision: true
16 | preview_mode: 1
17 | display_submitted: false
18 |
--------------------------------------------------------------------------------
/modules/bricks_default_paragraphs/bricks_default_paragraphs.features.yml:
--------------------------------------------------------------------------------
1 | excluded:
2 | - core.base_field_override.node.bricky_paragraphs.promote
3 | - language.content_settings.node.bricky_paragraphs
4 | required: true
5 |
--------------------------------------------------------------------------------
/modules/bricks_default_paragraphs/bricks_default_paragraphs.info.yml:
--------------------------------------------------------------------------------
1 | name: 'Bricks Default Paragraphs'
2 | description: 'Defaut setup for Bricks + Paragraphs.'
3 | package: Bricks
4 | type: module
5 | core: 8.x
6 | dependencies:
7 | - bricks
8 | - bricks_inline
9 | - bricks_revisions
10 | - field
11 | - language
12 | - menu_ui
13 | - node
14 | - paragraphs
15 | - paragraphs_demo
16 | - path
17 | - user
18 |
--------------------------------------------------------------------------------
/modules/bricks_default_paragraphs/bricks_default_paragraphs.install:
--------------------------------------------------------------------------------
1 | getStorage('paragraph')->create([
15 | 'type' => 'layout',
16 | ]);
17 | $layout->save();
18 |
19 | $data = file_get_contents(drupal_get_path('theme', 'bartik') . '/screenshot.png');
20 | $file = file_save_data($data, 'public://bartik.png');
21 | $image = $entity_manager->getStorage('paragraph')->create([
22 | 'type' => 'images',
23 | 'field_images_demo' => [
24 | 'target_id' => $file->id(),
25 | ],
26 | ]);
27 | $image->save();
28 |
29 | $text = $entity_manager->getStorage('paragraph')->create([
30 | 'type' => 'text',
31 | 'field_text_demo' => [
32 | 'value' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
33 | 'format' => 'basic_html',
34 | ],
35 | ]);
36 | $text->save();
37 |
38 | $wrapper = $entity_manager->getStorage('paragraph')->create([
39 | 'type' => 'wrapper',
40 | ]);
41 | $wrapper->save();
42 |
43 | $page = $entity_manager->getStorage('node')->create([
44 | 'type' => 'bricky_paragraphs',
45 | 'title' => 'Bricks + Paragraphs = ♥',
46 | 'field_body_paragraphs' => [
47 | ['depth' => 0, 'target_id' => $layout->id(), 'target_revision_id' => $layout->getRevisionId(), 'options' => ['layout' => 'layout_twocol']],
48 | ['depth' => 1, 'target_id' => $text->id(), 'target_revision_id' => $text->getRevisionId()],
49 | ['depth' => 1, 'target_id' => $image->id(), 'target_revision_id' => $image->getRevisionId()],
50 | ['depth' => 1, 'target_id' => $text->id(), 'target_revision_id' => $text->getRevisionId(), 'options' => ['css_class' => 'text-align-right']],
51 | ['depth' => 1, 'target_id' => $text->id(), 'target_revision_id' => $text->getRevisionId()],
52 | ],
53 | ]);
54 | $page->save();
55 | }
56 |
--------------------------------------------------------------------------------
/modules/bricks_default_paragraphs/config/install/core.entity_form_display.node.bricky_paragraphs.default.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | config:
5 | - field.field.node.bricky_paragraphs.field_body_paragraphs
6 | - node.type.bricky_paragraphs
7 | module:
8 | - bricks_inline
9 | - path
10 | id: node.bricky_paragraphs.default
11 | targetEntityType: node
12 | bundle: bricky_paragraphs
13 | mode: default
14 | content:
15 | created:
16 | type: datetime_timestamp
17 | weight: 4
18 | region: content
19 | settings: { }
20 | third_party_settings: { }
21 | field_body_paragraphs:
22 | weight: 1
23 | settings:
24 | form_mode: default
25 | label_singular: ''
26 | label_plural: ''
27 | allow_new: '1'
28 | allow_existing: '1'
29 | match_operator: CONTAINS
30 | override_labels: 0
31 | third_party_settings: { }
32 | type: bricks_tree_inline
33 | region: content
34 | langcode:
35 | type: language_select
36 | weight: 2
37 | region: content
38 | settings: { }
39 | third_party_settings: { }
40 | path:
41 | type: path
42 | weight: 7
43 | region: content
44 | settings: { }
45 | third_party_settings: { }
46 | promote:
47 | type: boolean_checkbox
48 | settings:
49 | display_label: true
50 | weight: 5
51 | region: content
52 | third_party_settings: { }
53 | sticky:
54 | type: boolean_checkbox
55 | settings:
56 | display_label: true
57 | weight: 6
58 | region: content
59 | third_party_settings: { }
60 | title:
61 | type: string_textfield
62 | weight: 0
63 | region: content
64 | settings:
65 | size: 60
66 | placeholder: ''
67 | third_party_settings: { }
68 | uid:
69 | type: entity_reference_autocomplete
70 | weight: 3
71 | settings:
72 | match_operator: CONTAINS
73 | size: 60
74 | placeholder: ''
75 | region: content
76 | third_party_settings: { }
77 | hidden: { }
78 |
--------------------------------------------------------------------------------
/modules/bricks_default_paragraphs/config/install/core.entity_view_display.node.bricky_paragraphs.default.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | config:
5 | - field.field.node.bricky_paragraphs.field_body_paragraphs
6 | - node.type.bricky_paragraphs
7 | module:
8 | - bricks
9 | - user
10 | id: node.bricky_paragraphs.default
11 | targetEntityType: node
12 | bundle: bricky_paragraphs
13 | mode: default
14 | content:
15 | field_body_paragraphs:
16 | weight: 0
17 | label: hidden
18 | settings:
19 | view_mode: default
20 | link: false
21 | third_party_settings: { }
22 | type: bricks_nested
23 | region: content
24 | links:
25 | weight: 1
26 | region: content
27 | settings: { }
28 | third_party_settings: { }
29 | hidden:
30 | langcode: true
31 |
--------------------------------------------------------------------------------
/modules/bricks_default_paragraphs/config/install/core.entity_view_display.node.bricky_paragraphs.teaser.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | config:
5 | - core.entity_view_mode.node.teaser
6 | - field.field.node.bricky_paragraphs.field_body_paragraphs
7 | - node.type.bricky_paragraphs
8 | module:
9 | - bricks
10 | - user
11 | id: node.bricky_paragraphs.teaser
12 | targetEntityType: node
13 | bundle: bricky_paragraphs
14 | mode: teaser
15 | content:
16 | field_body_paragraphs:
17 | type: bricks_nested
18 | weight: 0
19 | region: content
20 | label: hidden
21 | settings:
22 | view_mode: default
23 | link: false
24 | third_party_settings: { }
25 | links:
26 | weight: 1
27 | region: content
28 | settings: { }
29 | third_party_settings: { }
30 | hidden:
31 | langcode: true
32 |
--------------------------------------------------------------------------------
/modules/bricks_default_paragraphs/config/install/field.field.node.bricky_paragraphs.field_body_paragraphs.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | config:
5 | - field.storage.node.field_body_paragraphs
6 | - node.type.bricky_paragraphs
7 | - paragraphs.paragraphs_type.images
8 | - paragraphs.paragraphs_type.layout
9 | - paragraphs.paragraphs_type.text
10 | - paragraphs.paragraphs_type.wrapper
11 | module:
12 | - bricks_revisions
13 | id: node.bricky_paragraphs.field_body_paragraphs
14 | field_name: field_body_paragraphs
15 | entity_type: node
16 | bundle: bricky_paragraphs
17 | label: Body
18 | description: ''
19 | required: false
20 | translatable: false
21 | default_value: { }
22 | default_value_callback: ''
23 | settings:
24 | handler: 'default:paragraph'
25 | handler_settings:
26 | target_bundles:
27 | images: images
28 | layout: layout
29 | text: text
30 | wrapper: wrapper
31 | target_bundles_drag_drop:
32 | image_text:
33 | weight: '9'
34 | enabled: 0
35 | images:
36 | enabled: '1'
37 | weight: '10'
38 | layout:
39 | enabled: '1'
40 | weight: '11'
41 | nested_paragraph:
42 | weight: '12'
43 | enabled: 0
44 | text:
45 | enabled: '1'
46 | weight: '13'
47 | text_image:
48 | weight: '14'
49 | enabled: 0
50 | user:
51 | weight: '15'
52 | enabled: 0
53 | wrapper:
54 | enabled: '1'
55 | weight: '16'
56 | field_type: bricks_revisioned
57 |
--------------------------------------------------------------------------------
/modules/bricks_default_paragraphs/config/install/field.storage.node.field_body_paragraphs.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | module:
5 | - bricks_revisions
6 | - node
7 | - paragraphs
8 | id: node.field_body_paragraphs
9 | field_name: field_body_paragraphs
10 | entity_type: node
11 | type: bricks_revisioned
12 | settings:
13 | target_type: paragraph
14 | module: bricks_revisions
15 | locked: false
16 | cardinality: -1
17 | translatable: true
18 | indexes: { }
19 | persist_with_no_fields: false
20 | custom_storage: false
21 |
--------------------------------------------------------------------------------
/modules/bricks_default_paragraphs/config/install/node.type.bricky_paragraphs.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies:
4 | module:
5 | - menu_ui
6 | third_party_settings:
7 | menu_ui:
8 | available_menus:
9 | - main
10 | parent: 'main:'
11 | name: 'Bricky paragraphs'
12 | type: bricky_paragraphs
13 | description: 'Use bricky pages for your flexible content, such as ''Home'' or ''Company'' pages.'
14 | help: ''
15 | new_revision: true
16 | preview_mode: 1
17 | display_submitted: false
18 |
--------------------------------------------------------------------------------
/modules/bricks_default_paragraphs/config/install/paragraphs.paragraphs_type.layout.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies: { }
4 | id: layout
5 | label: Layout
6 | behavior_plugins: { }
7 |
--------------------------------------------------------------------------------
/modules/bricks_default_paragraphs/config/install/paragraphs.paragraphs_type.wrapper.yml:
--------------------------------------------------------------------------------
1 | langcode: en
2 | status: true
3 | dependencies: { }
4 | id: wrapper
5 | label: Wrapper
6 | behavior_plugins: { }
7 |
--------------------------------------------------------------------------------
/modules/bricks_dynamic/bricks_dynamic.info.yml:
--------------------------------------------------------------------------------
1 | name: Bricks Dynamic
2 | description: Allows to reference multiple entity types in a single Bricks field.
3 | package: Bricks
4 |
5 | type: module
6 | core: 8.x
7 |
8 | dependencies:
9 | - bricks
10 | - dynamic_entity_reference
11 | - inline_entity_form
--------------------------------------------------------------------------------
/modules/bricks_dynamic/bricks_dynamic.module:
--------------------------------------------------------------------------------
1 | getTriggeringElement();
22 | $parents = $triggering_element['#parents'];
23 | array_pop($parents);
24 | array_pop($parents);
25 | $parents[] = 'actions';
26 | $parents[] = 'entity_type';
27 |
28 | $entity_type = NestedArray::getValue($_POST, $parents);
29 |
30 | $labels = $reference_form['#ief_labels'];
31 | $ief_id = $reference_form['#ief_id'];
32 | /** @var \Drupal\field\Entity\FieldConfig $instance */
33 | $instance = $form_state->get(['inline_entity_form', $ief_id, 'instance']);
34 | $settings = $instance->getSettings();
35 |
36 | $reference_form['entity_id'] = [
37 | '#type' => 'entity_autocomplete',
38 | '#title' => t('@label', ['@label' => ucwords($labels['singular'])]),
39 | '#target_type' => $entity_type,
40 | '#selection_handler' => $settings[$entity_type]['handler'],
41 | '#selection_settings' => $settings[$entity_type]['handler_settings'],
42 | '#required' => TRUE,
43 | '#maxlength' => 255,
44 | ];
45 | }
46 |
--------------------------------------------------------------------------------
/modules/bricks_dynamic/src/Plugin/Field/FieldFormatter/BricksNestedDynamicFormatter.php:
--------------------------------------------------------------------------------
1 | moduleHandler = $module_handler;
66 | }
67 |
68 |
69 | /**
70 | * Creates an instance of the inline form handler for the current entity type.
71 | */
72 | protected function createInlineFormHandler() {
73 | if (!isset($this->inlineFormHandler) && $this->getEntityType()) {
74 | $entity_type = $this->getEntityType();
75 | $this->inlineFormHandler = $this->entityTypeManager->getHandler($entity_type, 'inline_form');
76 | }
77 | }
78 |
79 | protected function getEntityType() {
80 | $name = $this->fieldDefinition->getName();
81 |
82 | // TODO explain why this is used.
83 | if (isset($_POST[$name]['actions']['entity_type'])) {
84 | return $_POST[$name]['actions']['entity_type'];
85 | }
86 | $entity_types = DynamicEntityReferenceItem::getTargetTypes($this->fieldDefinition->getSettings());
87 |
88 | if (isset($entity_types[0])) {
89 | return $entity_types[0];
90 | }
91 | }
92 |
93 |
94 | /**
95 | * Returns the array of field settings.
96 | *
97 | * @return array
98 | * The array of settings.
99 | */
100 | protected function getFieldSettings() {
101 | $settings = $this->fieldDefinition->getSettings();
102 | $settings['target_type'] = $this->getEntityType();
103 | return $settings;
104 | }
105 |
106 | /**
107 | * Returns the value of a field setting.
108 | *
109 | * @param string $setting_name
110 | * The setting name.
111 | *
112 | * @return mixed
113 | * The setting value.
114 | */
115 | protected function getFieldSetting($setting_name) {
116 | if ($setting_name == 'target_type') {
117 | return $this->getEntityType();
118 | }
119 |
120 | return $this->fieldDefinition->getSetting($setting_name);
121 | }
122 |
123 |
124 | /**
125 | * Gets the target bundles for the current field.
126 | *
127 | * @return string[]
128 | * A list of bundles.
129 | */
130 | protected function getTargetBundles() {
131 | $target_bundles = [];
132 | $entity_type = $this->getEntityType();
133 | $field_settings = $this->getFieldSettings();
134 | if (isset($field_settings[$entity_type]) && isset($field_settings[$entity_type]['handler_settings']['target_bundles'])) {
135 | $entity_type_settings = $field_settings[$entity_type];
136 | $target_bundles = array_values($entity_type_settings['handler_settings']['target_bundles']);
137 | }
138 |
139 | return $target_bundles;
140 | }
141 |
142 | /**
143 | * Gets the access handler for the target entity type.
144 | *
145 | * @return \Drupal\Core\Entity\EntityAccessControlHandlerInterface
146 | * The access handler.
147 | */
148 | protected function getAccessHandler() {
149 | return $this->entityTypeManager->getAccessControlHandler($this->getEntityType());
150 | }
151 |
152 | /**
153 | * {@inheritdoc}
154 | */
155 | public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
156 | $element = parent::formElement($items, $delta, $element, $form, $form_state);
157 |
158 | $element['entities']['#widget'] = 'bricks_tree_inline';
159 |
160 | $allowed_entity_types = DynamicEntityReferenceItem::getTargetTypes($this->getFieldSettings());
161 |
162 | $entity_type_definitions = \Drupal::entityTypeManager()->getDefinitions();
163 |
164 | $entity_type_options = [];
165 |
166 | foreach ($allowed_entity_types as $allowed_entity_type) {
167 | if (isset($entity_type_definitions[$allowed_entity_type])) {
168 | $entity_type_options[$allowed_entity_type] = $entity_type_definitions[$allowed_entity_type]->getLabel();
169 | }
170 | }
171 |
172 | $element['actions']['entity_type'] = [
173 | '#type' => 'select',
174 | '#options' => $entity_type_options,
175 | '#default_value' => $this->getEntityType(),
176 | '#weight' => -9,
177 | '#ajax' => [
178 | 'callback' => [$this, 'rebuild'],
179 | 'wrapper' => 'inline-entity-form-' . $element['#ief_id']
180 | ]
181 | ];
182 |
183 | $element['actions']['bundle']['#element_validate'] = [[$this, 'correctBundle']];
184 |
185 | $entities = $form_state->get(['inline_entity_form', $this->getIefId(), 'entities']);
186 | foreach ($entities as $delta => $value) {
187 | _bricks_form_element_alter($element['entities'][$delta], $items[$delta], $value['entity']);
188 | }
189 |
190 | return $element;
191 | }
192 |
193 | public function rebuild(array &$form, FormStateInterface $form_state) {
194 | $parents = $form_state->getTriggeringElement()['#parents'];
195 | array_pop($parents);
196 | array_pop($parents);
197 | $fieldset = NestedArray::getValue($form, $parents);
198 |
199 | return $fieldset;
200 | }
201 |
202 | public function correctBundle(array &$element, FormStateInterface $form_state) {
203 | if (!isset($element['#options'][$element['#value']])) {
204 | $form_state->clearErrors();
205 | }
206 | }
207 |
208 | /**
209 | * {@inheritdoc}
210 | */
211 | public function massageFormValues(array $values, array $form, FormStateInterface $form_state) {
212 | $field_name = $this->fieldDefinition->getName();
213 | $field_value = $form_state->getValue($field_name);
214 |
215 | foreach ($values as $delta => $value) {
216 | if (isset($field_value['entities'][$delta])) {
217 | $values[$delta]['depth'] = $field_value['entities'][$delta]['depth'];
218 | if (isset($field_value['entities'][$delta]['options'])) {
219 | $values[$delta]['options'] = $field_value['entities'][$delta]['options'];
220 | }
221 | }
222 | }
223 |
224 | return $values;
225 |
226 | }
227 | }
--------------------------------------------------------------------------------
/modules/bricks_dynamic/src/Plugin/Field/FieldWidget/BricksTreeDynamicWidget.php:
--------------------------------------------------------------------------------
1 | render($variables['table']);
45 | }
46 | }
47 |
48 | /**
49 | * Hack: copy-and-paste from theme_inline_entity_form_entity_table().
50 | */
51 | function _inline_entity_form_preprocess_inline_entity_form_entity_table(&$variables) {
52 | $renderer = \Drupal::service('renderer');
53 | $form = $variables['form'];
54 | $entity_type = $form['#entity_type'];
55 |
56 | $fields = $form['#table_fields'];
57 | $has_tabledrag = \Drupal::entityTypeManager()->getHandler($entity_type, 'inline_form')->isTableDragEnabled($form);
58 |
59 | // Sort the fields by weight.
60 | uasort($fields, '\Drupal\Component\Utility\SortArray::sortByWeightElement');
61 |
62 | $header = [];
63 | if ($has_tabledrag) {
64 | $header[] = ['data' => '', 'class' => ['ief-tabledrag-header']];
65 | $header[] = ['data' => t('Sort order'), 'class' => ['ief-sort-order-header']];
66 | }
67 | // Add header columns for each field.
68 | $first = TRUE;
69 | foreach ($fields as $field_name => $field) {
70 | $column = ['data' => $field['label']];
71 | // The first column gets a special class.
72 | if ($first) {
73 | $column['class'] = ['ief-first-column-header'];
74 | $first = FALSE;
75 | }
76 | $header[] = $column;
77 | }
78 | $header[] = t('Operations');
79 |
80 | // Build an array of entity rows for the table.
81 | $rows = [];
82 | foreach (Element::children($form) as $key) {
83 | /** @var \Drupal\Core\Entity\FieldableEntityInterface $entity */
84 | $entity = $form[$key]['#entity'];
85 | $row_classes = ['ief-row-entity'];
86 | $cells = [];
87 | if ($has_tabledrag) {
88 | $cells[] = ['data' => '', 'class' => ['ief-tabledrag-handle']];
89 | $cells[] = $renderer->render($form[$key]['delta']);
90 | $row_classes[] = 'draggable';
91 | }
92 | // Add a special class to rows that have a form underneath, to allow
93 | // for additional styling.
94 | if (!empty($form[$key]['form'])) {
95 | $row_classes[] = 'ief-row-entity-form';
96 | }
97 |
98 | foreach ($fields as $field_name => $field) {
99 | $data = '';
100 | if ($field['type'] == 'label') {
101 | $data = $variables['form'][$key]['#label'];
102 | }
103 | elseif ($field['type'] == 'field' && $entity->hasField($field_name)) {
104 | $display_options = ['label' => 'hidden'];
105 | if (isset($field['display_options'])) {
106 | $display_options += $field['display_options'];
107 | }
108 | $data = $entity->get($field_name)->view($display_options);
109 | }
110 | elseif ($field['type'] == 'callback') {
111 | $arguments = [
112 | 'entity' => $entity,
113 | 'variables' => $variables,
114 | ];
115 | if (isset($field['callback_arguments'])) {
116 | $arguments = array_merge($arguments, $field['callback_arguments']);
117 | }
118 |
119 | $data = call_user_func_array($field['callback'], $arguments);
120 | }
121 |
122 | $cells[] = ['data' => $data, 'class' => ['inline-entity-form-' . $entity_type . '-' . $field_name]];
123 | }
124 |
125 | // Add the buttons belonging to the "Operations" column.
126 | $cells[] = $renderer->render($form[$key]['actions']);
127 | // Create the row.
128 | $rows[] = ['data' => $cells, 'class' => $row_classes];
129 | // If the current entity array specifies a form, output it in the next row.
130 | if (!empty($form[$key]['form'])) {
131 | $row = [
132 | ['data' => $renderer->render($form[$key]['form']), 'colspan' => count($fields) + 1],
133 | ];
134 | $rows[] = [
135 | 'data' => $row,
136 | 'class' => ['ief-row-form'],
137 | 'no_striping' => TRUE,
138 | ];
139 | }
140 | }
141 |
142 | if (!empty($rows)) {
143 | $tabledrag = [];
144 | if ($has_tabledrag) {
145 | $tabledrag = [
146 | [
147 | 'action' => 'order',
148 | 'relationship' => 'sibling',
149 | 'group' => 'ief-entity-delta',
150 | ],
151 | ];
152 | }
153 |
154 | $table = [
155 | '#type' => 'table',
156 | '#header' => $header,
157 | '#rows' => $rows,
158 | '#attributes' => [
159 | 'id' => 'ief-entity-table-' . $form['#id'],
160 | 'class' => ['ief-entity-table'],
161 | ],
162 | '#tabledrag' => $tabledrag,
163 | ];
164 |
165 | // return $renderer->render($table); // -
166 | $variables['table'] = $table; // +
167 | }
168 | }
169 |
--------------------------------------------------------------------------------
/modules/bricks_inline/src/Plugin/Field/FieldWidget/BricksTreeInlineWidget.php:
--------------------------------------------------------------------------------
1 | get(['inline_entity_form', $this->getIefId(), 'entities']);
34 | foreach ($entities as $delta => $value) {
35 | _bricks_form_element_alter($element['entities'][$delta], $items[$delta], $value['entity']);
36 | }
37 |
38 | return $element;
39 | }
40 |
41 | /**
42 | * {@inheritdoc}
43 | */
44 | public function massageFormValues(array $values, array $form, FormStateInterface $form_state) {
45 | $field_name = $this->fieldDefinition->getName();
46 | $field_value = $form_state->getValue($field_name);
47 |
48 | foreach ($values as $delta => $value) {
49 | if (isset($field_value['entities'][$delta])) {
50 | $values[$delta]['depth'] = $field_value['entities'][$delta]['depth'];
51 | $values[$delta]['options'] = $field_value['entities'][$delta]['options'];
52 | }
53 | }
54 |
55 | return $values;
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/modules/bricks_revisions/bricks_revisions.info.yml:
--------------------------------------------------------------------------------
1 | name: Bricks Revisions
2 | description: Allows to create revisioned Bricks.
3 | package: Bricks
4 |
5 | type: module
6 | core: 8.x
7 |
8 | dependencies:
9 | - bricks
10 | - entity_reference_revisions
11 |
--------------------------------------------------------------------------------
/modules/bricks_revisions/src/Plugin/Field/FieldType/BricksTreeRevisionedItem.php:
--------------------------------------------------------------------------------
1 |