From d35170001ca1d8db41763310f2dcd63a673745b2 Mon Sep 17 00:00:00 2001 From: Thomas Jakobi Date: Mon, 18 Mar 2024 12:36:15 +0100 Subject: [PATCH] Fix synchronized TVs never triggered [#202] --- core/components/babel/docs/changelog.md | 6 ++++++ core/components/babel/src/Babel.php | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/core/components/babel/docs/changelog.md b/core/components/babel/docs/changelog.md index 2a39461..86eeae7 100644 --- a/core/components/babel/docs/changelog.md +++ b/core/components/babel/docs/changelog.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.3.0] - TBA + +### Fixed + +- [#202] Fix synchronized TVs never triggered + ## [3.2.0] - 2024-02-07 ### Changed diff --git a/core/components/babel/src/Babel.php b/core/components/babel/src/Babel.php index bb11977..b991620 100644 --- a/core/components/babel/src/Babel.php +++ b/core/components/babel/src/Babel.php @@ -151,7 +151,7 @@ public function __construct(modX &$modx, array $config = []) 'contextKeys' => $this->modx->getOption($this->namespace . '.contextKeys', null, ''), 'restrictToGroup' => $this->getBooleanOption('restrictToGroup', [], true), 'displayText' => $this->modx->getOption($this->namespace . '.displayText', null, 'language'), - 'syncTvs' => $this->modx->getOption($this->namespace . '.syncTvs', null, ''), + 'syncTvs' => $this->getExplodeSeparatedOption($this->namespace . '.syncTvs', [], ''), 'babelTvName' => $this->modx->getOption($this->namespace . '.babelTvName', null, 'babelLanguageLinks'), ]); @@ -206,7 +206,7 @@ public function getOption(string $key, array $config = [], $default = null) } /** - * Get Boolean Option + * Get a boolean option. * * @param string $key * @param array $config @@ -219,6 +219,19 @@ public function getBooleanOption(string $key, array $config = [], $default = nul return ($option === 'true' || $option === true || $option === '1' || $option === 1); } + /** + * Get an exploded and trimmed value. + * + * @param string $value + * @param string $separator + * @return array + */ + public function getExplodeSeparatedOption(string $key, array $config = [], $default = null): array + { + $option = $this->getOption($key, $config, $default); + return ($option !== '') ? array_map('trim', explode(',', rtrim($option, " ,\t\n\r\0\x0B" ))) : []; + } + /** * Set a local configuration option. *