Skip to content
Snippets Groups Projects
Commit c457d50b authored by Alex Skrypnyk's avatar Alex Skrypnyk Committed by Deployer Robot
Browse files

Issue #3444381 by RichardGaunt, alex.skrypnyk: `civictheme_get_field_value`...

Issue #3444381 by RichardGaunt, alex.skrypnyk: `civictheme_get_field_value` helper function does not process some common core field types.
parent 621fdb99
No related branches found
No related tags found
No related merge requests found
......@@ -3,5 +3,5 @@ status: true
dependencies: { }
id: civictheme_banner
label: Banner
revision: 0
revision: false
description: ''
......@@ -3,5 +3,5 @@ status: true
dependencies: { }
id: civictheme_component_block
label: Component
revision: 0
revision: false
description: ''
......@@ -3,5 +3,5 @@ status: true
dependencies: { }
id: civictheme_mobile_navigation
label: 'Mobile Navigation'
revision: 0
revision: false
description: ''
......@@ -3,5 +3,5 @@ status: true
dependencies: { }
id: civictheme_search
label: Search
revision: 0
revision: false
description: ''
......@@ -3,5 +3,5 @@ status: true
dependencies: { }
id: civictheme_social_links
label: 'Social Links'
revision: 0
revision: false
description: 'List social link icons'
......@@ -26,7 +26,7 @@ function _civictheme_preprocess_menu_local_tasks(array &$variables): void {
'url' => $link['#link']['url']->toString(),
'is_new_window' => FALSE,
'is_external' => $link['#link']['url']->isExternal(),
'modifier_class' => $link['#active'] ? 'selected' : '',
'modifier_class' => $link['#active'] ? 'ct-tabs__tab--selected selected' : '',
'weight' => $link['#weight'] ?? 0,
];
}
......
......@@ -331,8 +331,11 @@ function civictheme_field_has_value(FieldableEntityInterface $entity, string $fi
/**
* Gets values from fields that CivicTheme regularly uses.
*
* It is not a replacement for the field api system for getting values. It gets
* commonly required types of values by CivicTheme.
* This function complements the field API system, providing a convenient way to
* retrieve commonly used field values specific to CivicTheme.
*
* If a field type is not listed, and you need to retrieve its value, consider
* using the field API system directly.
*
* @param \Drupal\Core\Entity\FieldableEntityInterface $entity
* Entity to check field existence.
......@@ -400,8 +403,11 @@ function civictheme_get_field_value(FieldableEntityInterface $entity, string $fi
break;
case 'text_long':
// Opinionated. We want to render field if single or allow view() to
// handle it if it's all values.
case 'text_with_summary':
// Opinionated.
// This implementation renders the field if it has a single value.
// If the field contains multiple values, it relies on view() to handle
// the rendering.
if ($only_first) {
$field = $field->first();
$field_value = $field->get('value')->getString();
......
......@@ -39,3 +39,6 @@ parameters:
reportUnmatched: false
- # Allow using Drupal::service() in Drush commands.
message: '#\Drupal calls should be avoided in classes, use dependency injection instead#'
- # Skip deprecation until upgrade to 10.3.
# @see https://www.drupal.org/node/3426517
message: '#Fetching deprecated class constant EXISTS_REPLACE#'
{"generatedAt":1718882467043,"builder":{"name":"webpack4"},"hasCustomBabel":false,"hasCustomWebpack":true,"hasStaticDirs":false,"hasStorybookEslint":false,"refCount":0,"packageManager":{"type":"npm","version":"8.19.4"},"storybookVersion":"6.5.16","language":"javascript","storybookPackages":{"@storybook/addons":{"version":"6.5.16"},"@storybook/html":{"version":"6.5.16"},"@storybook/preset-scss":{"version":"1.0.3"}},"framework":{"name":"html"},"addons":{"@storybook/addon-knobs":{"version":"6.4.0"},"@storybook/addon-essentials":{"options":{"controls":false,"docs":false,"actions":false},"version":"6.5.16"},"@storybook/addon-links":{"version":"6.5.16"},"@storybook/addon-a11y":{"version":"6.5.16"}}}
{"generatedAt":1718935118149,"builder":{"name":"webpack4"},"hasCustomBabel":false,"hasCustomWebpack":true,"hasStaticDirs":false,"hasStorybookEslint":false,"refCount":0,"packageManager":{"type":"npm","version":"8.19.4"},"storybookVersion":"6.5.16","language":"javascript","storybookPackages":{"@storybook/addons":{"version":"6.5.16"},"@storybook/html":{"version":"6.5.16"},"@storybook/preset-scss":{"version":"1.0.3"}},"framework":{"name":"html"},"addons":{"@storybook/addon-knobs":{"version":"6.4.0"},"@storybook/addon-essentials":{"options":{"controls":false,"docs":false,"actions":false},"version":"6.5.16"},"@storybook/addon-links":{"version":"6.5.16"},"@storybook/addon-a11y":{"version":"6.5.16"}}}
......@@ -42,7 +42,7 @@ abstract class CivicthemeBrowserTestBase extends BrowserTestBase {
$container = $this->container;
require_once dirname((string) $container->get('theme_handler')->rebuildThemeData()[$this->customTheme]->getPathname()) . '/theme-settings.provision.inc';
require_once dirname((string) $container->get('extension.list.theme')->reset()->getList()[$this->customTheme]->getPathname()) . '/theme-settings.provision.inc';
$modules = _civictheme_get_theme_dependencies($this->customTheme, $this->optionalDependencies);
$container->get('module_installer')->install($modules);
......
......@@ -1085,9 +1085,9 @@ function civictheme_enable_modules(bool $include_optional = TRUE): void {
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
*/
function _civictheme_get_theme_dependencies(string $theme_name, bool $include_optional = TRUE): array {
/** @var \Drupal\Core\Extension\ThemeHandler $theme_handler */
$theme_handler = \Drupal::getContainer()->get('theme_handler');
$theme_data = $theme_handler->rebuildThemeData();
/** @var \Drupal\Core\Extension\ThemeExtensionList $extension_list */
$extension_list = \Drupal::getContainer()->get('extension.list.theme');
$theme_data = $extension_list->reset()->getList();
// Merge dependencies from the theme's info file and from the 'optional'
// config. We are deliberately not including dependencies from the 'install'
......
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