This repository has been archived on 2025-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
drupalcampbristol/web/modules/contrib/ctools/ctools.module

65 lines
2.1 KiB
Plaintext
Raw Normal View History

2017-05-22 14:12:47 +00:00
<?php
/**
* Implements hook_theme().
*/
function ctools_theme($existing, $type, $theme, $path) {
return [
'ctools_wizard_trail' => [
'variables' => [
'wizard' => NULL,
'cached_values' => [],
'trail' => [],
'divider' => ' » ',
'step' => NULL,
],
],
'ctools_wizard_trail_links' => [
'variables' => [
'wizard' => NULL,
'cached_values' => [],
'trail' => [],
'divider' => ' » ',
'step' => NULL,
],
],
];
}
function template_preprocess_ctools_wizard_trail(&$variables) {
/** @var $wizard \Drupal\ctools\Wizard\FormWizardInterface|\Drupal\ctools\Wizard\EntityFormWizardInterface */
$wizard = $variables['wizard'];
$cached_values = $variables['cached_values'];
$trail = $variables['trail'];
$variables['step'] = $wizard->getStep($cached_values);
foreach ($wizard->getOperations($cached_values) as $step => $operation) {
$trail[$step] = !empty($operation['title']) ? $operation['title'] : '';
}
$variables['trail'] = $trail;
}
function template_preprocess_ctools_wizard_trail_links(&$variables) {
/** @var $wizard \Drupal\ctools\Wizard\FormWizardInterface|\Drupal\ctools\Wizard\EntityFormWizardInterface */
$wizard = $variables['wizard'];
$cached_values = $variables['cached_values'];
$trail = $variables['trail'];
$variables['step'] = $wizard->getStep($cached_values);
foreach ($wizard->getOperations($cached_values) as $step => $operation) {
$parameters = $wizard->getNextParameters($cached_values);
// Override step to be the step we want.
$parameters['step'] = $step;
$trail[$step] = [
'title' => !empty($operation['title']) ? $operation['title'] : '',
'url' => new \Drupal\Core\Url($wizard->getRouteName(), $parameters),
];
}
$variables['trail'] = $trail;
}
function ctools_condition_info_alter(&$definitions) {
// If the node_type's class is unaltered, use a custom ctools implementation.
if (isset($definitions['node_type']) && $definitions['node_type']['class'] == 'Drupal\node\Plugin\Condition\NodeType') {
$definitions['node_type']['class'] = 'Drupal\ctools\Plugin\Condition\NodeType';
}
}