Skip to content
Snippets Groups Projects
Commit 8c208810 authored by Jürgen Haas's avatar Jürgen Haas
Browse files

Issue #3486193 by jurgenhaas, kopeboy, danielspeicher: eca_cache Lifetime until expiry improvements

parent 0dae778b
No related branches found
No related tags found
1 merge request!513Issue #3469697 by jurgenhaas, freelock, mxh, lexsoft: ECA Form breaks complex IEF widget
Pipeline #512104 canceled
......@@ -125,7 +125,7 @@ abstract class CacheActionBase extends ConfigurableActionBase {
*/
protected function getCacheTags(): array {
$tags = [];
if ($this->configuration['tags'] !== '') {
if (trim($this->tokenService->replaceClear($this->configuration['tags'])) !== '') {
$tags = array_values(DataTransferObject::buildArrayFromUserInput($this->configuration['tags']));
}
return $tags;
......
......@@ -2,6 +2,7 @@
namespace Drupal\eca_cache\Plugin\Action;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\eca\Service\YamlParser;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -50,7 +51,13 @@ abstract class CacheWrite extends CacheActionBase {
$value = $this->tokenService->getOrReplace($value);
}
$expire = (int) ($this->configuration['expire'] ?? -1);
$expire = trim($this->tokenService->getOrReplace($this->configuration['expire']));
if ($expire === '') {
$expire = CacheBackendInterface::CACHE_PERMANENT;
}
else {
$expire = (int) $expire;
}
$tags = $this->getCacheTags();
$cache->set($key, $value, $expire, $tags);
......@@ -89,11 +96,12 @@ abstract class CacheWrite extends CacheActionBase {
];
$form['expire'] = [
'#type' => 'number',
'#title' => $this->t('Lifetime until expiry'),
'#title' => $this->t('Expiration time'),
'#description' => $this->t('The timestamp in seconds when the cached item expires. Set to -1 for unlimited lifetime.'),
'#default_value' => $this->configuration['expire'],
'#required' => TRUE,
'#weight' => -20,
'#eca_token_replacement' => TRUE,
];
$form['tags'] = [
'#type' => 'textarea',
......@@ -103,6 +111,7 @@ abstract class CacheWrite extends CacheActionBase {
]),
'#default_value' => $this->configuration['tags'],
'#weight' => -10,
'#eca_token_replacement' => TRUE,
];
return parent::buildConfigurationForm($form, $form_state);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment