Skip to content
This repository has been archived by the owner on Nov 16, 2021. It is now read-only.

Commit

Permalink
Decouple the bundled content types (#205 & #237)
Browse files Browse the repository at this point in the history
  • Loading branch information
balsama committed Dec 8, 2016
1 parent 1ea2fde commit bc28695
Show file tree
Hide file tree
Showing 37 changed files with 197 additions and 144 deletions.
4 changes: 4 additions & 0 deletions lightning.services.yml
Expand Up @@ -4,3 +4,7 @@ services:
arguments:
- '@app.root'
- '@site.path'
lightning.form_helper:
class: '\Drupal\lightning\FormHelper'
arguments:
- '@element_info'
@@ -1,7 +1,8 @@
name: Lightning
name: Lightning Core
core: 8.x
type: module
description: Core functionality for the Lightning distribution.
package: Lightning
description: Shared functionality for the Lightning distribution.
dependencies:
# config dependencies
- menu_ui
Expand All @@ -10,3 +11,5 @@ dependencies:
- path
- text
- user
components:
- lightning_page
14 changes: 3 additions & 11 deletions modules/lightning_features/lightning_core/lightning_core.module
Expand Up @@ -228,18 +228,10 @@ function lightning_core_form_system_modules_alter(array &$form) {
*/
function lightning_core_form_user_form_alter(array &$form) {
if (isset($form['account']['roles'])) {
$element = &$form['account']['roles'];
// Ensure the standard process functions run first.
\Drupal::service('lightning.form_helper')
->applyStandardProcessing($form['account']['roles']);

// Always ensure the standard #process function(s) run first.
if (empty($element['#process'])) {
$element_info = \Drupal::service('plugin.manager.element_info')
->createInstance($element['#type'])
->getInfo();

if (isset($element_info['#process'])) {
$element['#process'] = $element_info['#process'];
}
}
$form['account']['roles']['#process'][] = 'lightning_core_set_role_descriptions';
}
}
Expand Down
Expand Up @@ -14,29 +14,26 @@ targetEntityType: node
bundle: page
mode: default
content:
body:
type: text_textarea_with_summary
weight: 6
title:
type: string_textfield
weight: 0
settings:
rows: 9
summary_rows: 3
size: 60
placeholder: ''
third_party_settings: { }
uid:
type: entity_reference_autocomplete
weight: 1
settings:
match_operator: CONTAINS
size: 60
placeholder: ''
third_party_settings: { }
created:
type: datetime_timestamp
weight: 2
settings: { }
third_party_settings: { }
field_meta_tags:
type: metatag_firehose
weight: 7
settings: { }
third_party_settings: { }
path:
type: path
weight: 5
settings: { }
third_party_settings: { }
promote:
type: boolean_checkbox
settings:
Expand All @@ -49,19 +46,33 @@ content:
display_label: true
weight: 4
third_party_settings: { }
title:
type: string_textfield
weight: 0
path:
type: path
weight: 5
settings: { }
third_party_settings: { }
body:
type: text_textarea_with_summary
weight: 6
settings:
size: 60
rows: 9
summary_rows: 3
placeholder: ''
third_party_settings: { }
uid:
type: entity_reference_autocomplete
weight: 1
field_meta_tags:
type: metatag_firehose
weight: 7
settings: { }
third_party_settings: { }
scheduled_update:
type: inline_entity_form_complex
weight: 8
settings:
override_labels: false
label_singular: ''
label_plural: ''
allow_new: true
allow_existing: false
match_operator: CONTAINS
size: 60
placeholder: ''
third_party_settings: { }
hidden: { }
Expand Up @@ -8,6 +8,16 @@ third_party_settings:
available_menus:
- main
parent: 'main:'
workbench_moderation:
enabled: true
allowed_moderation_states:
- archived
- draft
- needs_review
- published
default_moderation_state: draft
lightning_workflow:
embargo: true
name: 'Basic page'
type: page
description: 'Use <em>basic pages</em> for your static content, such as an ''About us'' page.'
Expand Down
@@ -0,0 +1,7 @@
name: Basic Page
package: Lightning
core: 8.x
type: module
description: Provides a "Basic Page" content type that is, indeed, very basic.
dependencies:
- lightning_core
Expand Up @@ -9,3 +9,5 @@ dependencies:
# decoupled; see the issue summary in https://www.drupal.org/node/2600634.
- page_manager
- panelizer
components:
- lightning_landing_page
@@ -0,0 +1,7 @@
name: Landing Page
package: Lightning
core: 8.x
type: module
description: Provides a content type which allows you to build free-form one-off landing pages.
dependencies:
- lightning_layout
Expand Up @@ -4,8 +4,6 @@ dependencies:
config:
- field.field.scheduled_update.multiple_node_embargo.field_moderation_state_1
- scheduled_updates.scheduled_update_type.multiple_node_embargo
_core:
default_config_hash: TaoCbKG82-4tHEGba1IBuPl9liE6lSMUO14FtFyYH34
id: scheduled_update.multiple_node_embargo.default
targetEntityType: scheduled_update
bundle: multiple_node_embargo
Expand Down
Expand Up @@ -4,8 +4,6 @@ dependencies:
config:
- field.field.scheduled_update.node_embargo.field_moderation_state
- scheduled_updates.scheduled_update_type.node_embargo
_core:
default_config_hash: XLM4XxWVsRabgIZ4Wt5dwKtYQJzf82ddxM1k4SpkCxw
id: scheduled_update.node_embargo.default
targetEntityType: scheduled_update
bundle: node_embargo
Expand Down

This file was deleted.

Expand Up @@ -4,8 +4,6 @@ dependencies:
config:
- field.storage.scheduled_update.field_moderation_state_1
- scheduled_updates.scheduled_update_type.multiple_node_embargo
_core:
default_config_hash: _jhq30skbuYSA2hgaBAOtm2J-oh2SOvwx9HO7f5fMuk
id: scheduled_update.multiple_node_embargo.field_moderation_state_1
field_name: field_moderation_state_1
entity_type: scheduled_update
Expand Down
Expand Up @@ -4,8 +4,6 @@ dependencies:
config:
- field.storage.scheduled_update.field_moderation_state
- scheduled_updates.scheduled_update_type.node_embargo
_core:
default_config_hash: UUdOywcjdHs2k7tBQ85t84KEGF2xb3HTCFVoG53xMVM
id: scheduled_update.node_embargo.field_moderation_state
field_name: field_moderation_state
entity_type: scheduled_update
Expand Down
Expand Up @@ -4,8 +4,6 @@ dependencies:
module:
- node
- scheduled_updates
_core:
default_config_hash: 96C_n8O06F-YdI1bYCxqWc6Qt5LUhGopvsYBIY9E1Mo
id: node.scheduled_update
field_name: scheduled_update
entity_type: node
Expand Down
Expand Up @@ -4,8 +4,6 @@ dependencies:
module:
- scheduled_updates
- workbench_moderation
_core:
default_config_hash: _nHUpwBqKtOytog5Y0yrOVeXQIXO_qegv0S_Gs25IOY
id: scheduled_update.field_moderation_state
field_name: field_moderation_state
entity_type: scheduled_update
Expand Down
Expand Up @@ -4,8 +4,6 @@ dependencies:
module:
- scheduled_updates
- workbench_moderation
_core:
default_config_hash: UfGyni46MHC7LmvLL-w3lvoMcZIahq2Hw-p-6iDFFkk
id: scheduled_update.field_moderation_state_1
field_name: field_moderation_state_1
entity_type: scheduled_update
Expand Down
@@ -1,8 +1,6 @@
langcode: en
status: true
dependencies: { }
_core:
default_config_hash: bsDvum-J70OIROUKs71tIZHm8tVkLQGImNDr4THMbx0
id: multiple_node_embargo
label: 'Publish multiple nodes at a certain time'
update_entity_type: node
Expand Down
@@ -1,8 +1,6 @@
langcode: en
status: true
dependencies: { }
_core:
default_config_hash: Lx-emuGAmsJhShPvVJG03Ah7VtuJNjMuzHBjkG5vQzw
id: node_embargo
label: 'Publish single node at certain time'
update_entity_type: node
Expand Down
Expand Up @@ -4,8 +4,6 @@ dependencies:
module:
- node
- user
_core:
default_config_hash: VrF4HC3OxIEMuLWUxvdZGAJV23vqV75Vif-Ly0Tl1n4
id: moderation_history
label: 'Moderation History'
module: views
Expand Down
Expand Up @@ -5,57 +5,13 @@
* Contains installation and update routines for Lightning Workflow.
*/

use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\node\Entity\NodeType;
use Drupal\views\Entity\View;

/**
* Implements hook_install().
*/
function lightning_workflow_install() {
$module = 'workbench_moderation';

// Enable moderation for the Page content type, if it exists.
$page_type = NodeType::load('page');
if ($page_type) {
$page_type
->setThirdPartySetting($module, 'enabled', TRUE)
->setThirdPartySetting($module, 'allowed_moderation_states', [
'archived',
'draft',
'needs_review',
'published',
])
->setThirdPartySetting($module, 'default_moderation_state', 'draft')
->save();

/** @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $form_display */
$form_display = EntityFormDisplay::load('node.page.default');
if ($form_display) {
$weights = array_map(
function (array $component) {
return $component['weight'];
},
$form_display->getComponents()
);

sort($weights);
$form_display->setComponent('scheduled_update', [
'type' => 'inline_entity_form_complex',
'weight' => end($weights) + 1,
'settings' => [
'override_labels' => FALSE,
'label_singular' => '',
'label_plural' => '',
'allow_new' => TRUE,
'allow_existing' => FALSE,
'match_operator' => 'CONTAINS',
],
'third_party_settings' => [],
])->save();
}
}

// Set up content type-specific permissions.
lightning_workflow_update_8001();

Expand Down

0 comments on commit bc28695

Please sign in to comment.