Skip to content

Commit

Permalink
Fix synchronized TVs never triggered [#202]
Browse files Browse the repository at this point in the history
  • Loading branch information
Jako committed Mar 18, 2024
1 parent ba32949 commit d351700
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
6 changes: 6 additions & 0 deletions core/components/babel/docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 15 additions & 2 deletions core/components/babel/src/Babel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
]);

Expand Down Expand Up @@ -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
Expand All @@ -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.
*
Expand Down

0 comments on commit d351700

Please sign in to comment.