Skip to content

Commit

Permalink
Merge branch 'develop' into feature/webform-review-component
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony-malkoun authored Feb 26, 2025
2 parents 484d3e9 + d5510d1 commit fbd4602
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 17 deletions.
36 changes: 29 additions & 7 deletions modules/tide_landing_page/tide_landing_page.module
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ function tide_landing_page_form_node_form_alter(&$form, FormStateInterface $form
}
}
}
$form['#validate'][] = 'tide_landing_page_header_style_node_form_validate';
}

// Add conditional field for show table of content.
Expand All @@ -170,6 +171,34 @@ function tide_landing_page_form_node_form_alter(&$form, FormStateInterface $form
}
}

/**
* Node form validate callback for Header style.
*/
function tide_landing_page_header_style_node_form_validate(array &$form, FormStateInterface $form_state) {
$header_style = $form_state->getValue('_header_style_options');
$hero_theme_value = $form_state->getValue(['field_landing_page_hero_theme', 0, 'value']);
$valid = TRUE;
$message = '';
switch ($header_style) {
case 'fullwidth':
if ($hero_theme_value !== 'dark') {
$valid = FALSE;
$message = t('When "Header style" is "Full-width background image", the "Page title display style" must be "Reverse blocked text".');
}
break;

case 'cta':
if ($hero_theme_value !== 'light') {
$valid = FALSE;
$message = t('When "Header style" is "Call to action banner", the "Page title display style" must be "Default".');
}
break;
}
if (!$valid) {
$form_state->setErrorByName('field_landing_page_hero_theme', $message);
}
}

/**
* Implements hook_field_widget_single_element_WIDGET_TYPE_form_alter().
*/
Expand Down Expand Up @@ -435,13 +464,6 @@ function _tide_landing_page_form_node_form_process(array $form, FormStateInterfa
],
];

$form['field_landing_page_hero_theme']['#states']['disabled'] = [
':input[name="_header_style_options"]' => [
['value' => 'fullwidth'],
['value' => 'cta'],
],
];

$form['field_landing_page_hero_image']['#states']['visible'] = [
':input[name="_header_style_options"]' => [
['value' => 'fullwidth'],
Expand Down
5 changes: 1 addition & 4 deletions modules/tide_publication/tide_publication.module
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ function tide_publication_form_node_form_alter(&$form, FormStateInterface $form_
$form['field_node_display_headings']['widget']['#default_value'] = 'showH2';
}
}
$form['#validate'][] = 'tide_landing_page_header_style_node_form_validate';
}
}

Expand Down Expand Up @@ -125,10 +126,6 @@ function _tide_publication_form_node_form_process(array $form, FormStateInterfac
],
];

$form['field_landing_page_hero_theme']['#states']['enabled'] = [
':input[name="_header_style_options"]' => ['value' => 'corner'],
];

$form['field_landing_page_hero_image']['#states']['visible'] = [
':input[name="_header_style_options"]' => [
['value' => 'fullwidth'],
Expand Down
26 changes: 20 additions & 6 deletions modules/tide_search/src/Commands/TideSearchCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,23 @@
class TideSearchCommands extends DrushCommands {

/**
* Audit nodeids that needs to be published/indexed based on search index.
* Audits node ids that needs to be published/indexed based on search index.
*
* @usage drush tide-search-audit-nodes
* Update the domains on the site taxonomy based on an environment variable.
* The list of items not in the search index can be added using the following
* command where '--id-list' is the output from running
* 'tide:search-audit-nodes'
*
* 'drush search-api:index-sample --datasource=entity:node --id-list=123,456'
*
* @param string $indexId
* The name of the Search API index to audit, e.g. 'node'.
*
* @return string
* A comma delimited list of ids that can be passed to
* 'drush search_api:index-sample'
*
* @usage drush tide-search-audit-nodes node
* Audit 'node' index for missing items
*
* @command tide:search-audit-nodes
* @aliases tide-san,tide-search-audit-nodes
Expand Down Expand Up @@ -91,14 +104,14 @@ public static function getNidsFromSearchIndex($indexId) {
throw new ConsoleException(t('@index was not found'));
}
$total = $indexes[$indexId]->getTrackerInstance()->getTotalItemsCount();
$no_of_batches = ceil($total / 1000);
// If the result set is more than 1000 then run it in batch.
$no_of_batches = ceil($total / 500);
// If the result set is more than 500 then run it in batch.
if ($no_of_batches > 1) {
$nid_starting_point = 0;
for ($i = 1; $i <= $no_of_batches; $i++) {
try {
$query = $indexes[$indexId]->query();
$query->range(0, 1000);
$query->range(0, 500);
$query->sort('nid');
$query->addCondition('nid', $nid_starting_point, '>');
$results = $query->execute();
Expand Down Expand Up @@ -146,6 +159,7 @@ public static function getPublishedNodeIds() {
->condition('type', 'alert', '!=')
->condition('status', 1)
->sort('nid')
->accessCheck(FALSE)
->condition('nid', $pointer, '>')
->range(0, 100)
->execute();
Expand Down

0 comments on commit fbd4602

Please sign in to comment.