Skip to content
Snippets Groups Projects
Commit 36cedfbe authored by Rajab Natshah's avatar Rajab Natshah
Browse files

Issue #3122672: Start a 9.0.x branch for Varbase and Varbase Project to integrate with Drupal 9

parent 2c2fb677
No related branches found
No related tags found
No related merge requests found
......@@ -20,7 +20,8 @@ config_bit:
- varbase_webform
- varbase_workflow
- varbase_page
- varbase_landing
- varbase_layout_builder
- vlplb
- varbase_total_control
- varbase_default_content
- varbase_tour
......
......@@ -13,6 +13,7 @@ use Drupal\varbase\Form\ConfigureMultilingualForm;
use Drupal\varbase\Form\AssemblerForm;
use Drupal\varbase\Form\DevelopmentToolsAssemblerForm;
use Drupal\varbase\Entity\VarbaseEntityDefinitionUpdateManager;
use Drupal\node\Entity\Node;
/**
* Implements hook_form_FORM_ID_alter() for install_configure_form().
......@@ -23,7 +24,7 @@ function varbase_form_install_configure_form_alter(&$form, FormStateInterface $f
// Add a placeholder as example that one can choose an arbitrary site name.
$form['site_information']['site_name']['#attributes']['placeholder'] = t('My Official Site Name');
// Default site email noreply@vardot.com .
// Default site email noreply(at)vardot.com.
$form['site_information']['site_mail']['#default_value'] = 'noreply@vardot.com';
$form['site_information']['site_mail']['#attributes']['style'] = 'width: 25em;';
......@@ -224,6 +225,21 @@ function varbase_assemble_extra_components(array &$install_state) {
// Uninstall list of not needed modules after the config had been loaded.
// To be loaded from a ConfigBit yml file.
$uninstall_components = ['varbase_default_content'];
if (isset($selected_extra_features['varbase_heroslider_media'])
&& $selected_extra_features['varbase_heroslider_media'] == TRUE) {
$batch['operations'][] = ['varbase_install_component', (array) 'enabled_varbase_heroslider_media_content'];
$uninstall_components[] = 'enabled_varbase_heroslider_media_content';
}
else {
$batch['operations'][] = ['varbase_install_component', (array) 'disabled_varbase_heroslider_media_content'];
$uninstall_components[] = 'disabled_varbase_heroslider_media_content';
}
// Reset timestamp for nodes.
$node_ids = [1];
$batch['operations'][] = ['varbase_reset_timestamp_for_nodes', (array) $node_ids];
if (count($uninstall_components) > 0) {
foreach ($uninstall_components as $uninstall_component) {
$batch['operations'][] = ['varbase_uninstall_component', (array) $uninstall_component];
......@@ -415,6 +431,18 @@ function varbase_config_bit_for_multilingual($enable_multilingual) {
// Each module will manage its multilingual config.
}
/**
* Batch function to Install needed modules.
*
* @param string|array $install_component
* Name of the extra component.
*/
function varbase_install_component($install_component) {
if (!\Drupal::moduleHandler()->moduleExists($install_component)) {
\Drupal::service('module_installer')->install([$install_component], FALSE);
}
}
/**
* Batch function to Uninstall list of not needed modules.
*
......@@ -429,6 +457,20 @@ function varbase_uninstall_component($uninstall_component) {
}
}
/**
* Batch to reset timestamp for selected nodes.
*
* @param int|array $nid
* The Node ID.
*/
function varbase_reset_timestamp_for_nodes($nid) {
$node = Node::load($nid);
if (isset($node)) {
$node->created = \Drupal::time()->getCurrentTime();
$node->save();
}
}
/**
* Varbase after install finished.
*
......@@ -458,30 +500,6 @@ function varbase_after_install_finished(array &$install_state) {
$config_factory->setData($config_data)->save(TRUE);
}
// Enable Simple Workflow for all content types on new Varbase Installations.
if (\Drupal::moduleHandler()->moduleExists('varbase_workflow')) {
$node_types = \Drupal::entityTypeManager()->getStorage('node_type')->loadMultiple();
foreach ($node_types as $node_type) {
$config_factory = \Drupal::service('config.factory');
$workflow_type_settings = $config_factory->getEditable('workflows.workflow.varbase_simple_workflow')->get('type_settings');
if (isset($workflow_type_settings['entity_types'])) {
if (isset($workflow_type_settings['entity_types']['node'])) {
if (!in_array($node_type, $workflow_type_settings['entity_types']['node'])) {
$workflow_type_settings['entity_types']['node'][] = $node_type->id();
}
}
else {
$workflow_type_settings['entity_types']['node'] = [];
$workflow_type_settings['entity_types']['node'][] = $node_type->id();
}
$config_factory->getEditable('workflows.workflow.varbase_simple_workflow')->set('type_settings', $workflow_type_settings)->save(TRUE);
}
}
}
// Entity updates to clear up any mismatched entity and/or field definitions
// And Fix changes were detected in the entity type and field definitions.
\Drupal::classResolver()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment