Skip to content

Commit

Permalink
Issue #3442343: Change the reset of timestamp for default content. On…
Browse files Browse the repository at this point in the history
…ly for the Homepage, blog, and Contact Us default content pages, and change conditional fields for varbase demo with default selected recipes
  • Loading branch information
Natshah committed May 12, 2024
1 parent 3b4b980 commit 12e57b4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 81 deletions.
14 changes: 7 additions & 7 deletions configbit/extra.components.varbase.bit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ config_bit:
description: 'Adds an automatic checker tool for accessibility with the integration of the <a href="https://www.drupal.org/project/editoria11y" target="_blank">Editoria11y Accessibility Checker</a>, a user-friendly tool dedicated to automatically identifying and addressing straightforward accessibility issues in various contexts.'
selected: true
config_form: false
in_varbase_demo: true
in_varbase_demo: false
vmi:
title: "View Modes Inventory"
description: "The most common view modes you'll need for almost any site. This will provide you with a set of content <em>View Modes</em> for various teaser styles. All of which are mobile-first, media-aware, and ready for you to customize your site."
Expand All @@ -39,13 +39,13 @@ config_bit:
description: 'Provides the necessary tools to build carousels in your website. You will be able to create carousels on the spot and place it anywhere in the site.'
selected: false
config_form: false
in_varbase_demo: true
in_varbase_demo: false
varbase_search:
title: "Varbase Search"
description: 'A suite of site search engine tools to help you build better search performance, customization, and search experience. Built using <a href="https://www.drupal.org/project/search_api" target="_blank">Search API</a>.'
selected: false
config_form: false
in_varbase_demo: true
in_varbase_demo: false
varbase_blog:
title: "Varbase Blog"
description: "Provides the necessary tools to build blogs in your website."
Expand All @@ -58,22 +58,22 @@ config_bit:
selected: false
config_form: true
formbit: "src/FormBit/varbase_auth.formbit.php"
in_varbase_demo: true
in_varbase_demo: false
varbase_api:
title: "Varbase API"
description: "A JSON:API implementation with authentication and authorization that allows for easy ingestion of content by other applications."
selected: false
config_form: false
in_varbase_demo: true
in_varbase_demo: false
google_analytics:
title: "Google Analytics"
description: 'Adds the <a href="https://www.drupal.org/project/google_analytics" target="_blank">Google Analytics</a> web statistics tracking system to your website.'
selected: false
config_form: false
in_varbase_demo: true
in_varbase_demo: false
google_tag:
title: "Google Tag Manager"
description: 'Adds an integration with the <a href="https://www.drupal.org/project/google_tag" target="_blank">Google Tag Manager</a> (GTM) application.'
selected: false
config_form: false
in_varbase_demo: true
in_varbase_demo: false
23 changes: 0 additions & 23 deletions src/Form/AssemblerForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ public function buildForm(array $form, FormStateInterface $form_state, array &$i
if (count($demoContent) > 0) {
$form['demo_content'] = [
'#type' => 'fieldset',
// '#title' => $this->t('Demo'),
];

foreach ($demoContent as $demo_content_key => $demo_content_info) {
Expand Down Expand Up @@ -163,7 +162,6 @@ public function buildForm(array $form, FormStateInterface $form_state, array &$i

$form['extra_features'] = [
'#type' => 'fieldset',
// '#title' => $this->t('Recipes'),
];

foreach ($extraFeatures as $extra_feature_key => $extra_feature_info) {
Expand Down Expand Up @@ -202,37 +200,16 @@ public function buildForm(array $form, FormStateInterface $form_state, array &$i
'disabled' => [
':input[name="varbase_demo"]' => ['checked' => TRUE],
],
'enabled' => [
':input[name="varbase_demo"]' => ['checked' => FALSE],
],
];
}
else {
$form['extra_features'][$extra_feature_key]['#states'] = [
'disabled' => [
':input[name="varbase_demo"]' => ['checked' => TRUE],
],
'enabled' => [
':input[name="varbase_demo"]' => ['checked' => FALSE],
],
'checked' => [
':input[name="varbase_demo"]' => ['checked' => TRUE],
],
'unchecked' => [
':input[name="varbase_demo"]' => ['checked' => FALSE],
],
];
}
}
else {
if ($checkbox_selected) {
$form['extra_features'][$extra_feature_key]['#states'] = [
'disabled' => [
':input[name="varbase_demo"]' => ['checked' => TRUE],
],
'enabled' => [
':input[name="varbase_demo"]' => ['checked' => FALSE],
],
];
}
}
Expand Down
59 changes: 8 additions & 51 deletions varbase.profile
Original file line number Diff line number Diff line change
Expand Up @@ -542,58 +542,15 @@ function varbase_uninstall_component($uninstall_component) {
*/
function varbase_reset_timestamp_for_default_content($reset) {

// Reset timestamp for default content.
if ($reset) {
// Reset timestamp for all file's default content.
$file_storage = \Drupal::service('entity_type.manager')->getStorage('file');
$file_ids = $file_storage->getQuery()
->accessCheck(FALSE)
->execute();

if (isset($file_ids)
&& is_array($file_ids)
&& count($file_ids) > 0) {

foreach ($file_ids as $fid) {
$file = \Drupal::service('entity_type.manager')->getStorage('file')->load($fid);
if (isset($file)) {
$file->set('created', \Drupal::time()->getCurrentTime());
$file->save();
}
}
}

// Reset timestamp for all Media's default content.
$media_storage = \Drupal::service('entity_type.manager')->getStorage('media');
$media_ids = $media_storage->getQuery()
->accessCheck(FALSE)
->execute();

if (isset($media_ids)
&& is_array($media_ids)
&& count($media_ids) > 0) {

foreach ($media_ids as $mid) {
$media = \Drupal::service('entity_type.manager')->getStorage('media')->load($mid);
if (isset($media)) {
$media->set('created', \Drupal::time()->getCurrentTime());
$media->save();
}
}
}

// Reset timestamp for all Node's default content.
$node_storage = \Drupal::service('entity_type.manager')->getStorage('node');
$node_ids = $node_storage->getQuery()->accessCheck(FALSE)->execute();
if (isset($node_ids)
&& is_array($node_ids)
&& count($node_ids) > 0) {

foreach ($node_ids as $nid) {
$node = \Drupal::service('entity_type.manager')->getStorage('node')->load($nid);
if (isset($node)) {
$node->set('created', \Drupal::time()->getCurrentTime());
$node->save();
}
// Only for the Homepage, blog, and Contact Us default content pages.
$node_ids = [1, 2, 3];
foreach ($node_ids as $nid) {
$node = \Drupal::service('entity_type.manager')->getStorage('node')->load($nid);
if (isset($node)) {
$node->set('created', \Drupal::time()->getCurrentTime());
$node->save();
}
}
}
Expand Down

0 comments on commit 12e57b4

Please sign in to comment.