Skip to content

Commit

Permalink
Get getNotificationsStatusLoop interval from YAML config
Browse files Browse the repository at this point in the history
  • Loading branch information
adriendupuis committed Mar 13, 2024
1 parent 230f163 commit 1608325
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/bundle/Controller/NotificationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function renderNotificationsPageAction(int $page): Response
'page' => $page,
'pagination' => $pagination,
'notifications' => $notifications,
'notifications_count_interval' => $this->configResolver->getParameter('notifications.count.interval'),
'notifications_count_interval' => $this->configResolver->getParameter('notification_count.interval'),
'pager' => $pagerfanta,
])->getContent());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
*
* Example configuration:
* ```yaml
* ezpublish:
* ibexa:
* system:
* admin_group: # configuration per siteaccess or siteaccess group
* notifications:
* warning: # type of notification
* timeout: 5000 # in milliseconds
* notification_count:
* interval: # type of notification
* timeout: 60000 # in milliseconds
* ```
*/
class Notifications extends AbstractParser
Expand All @@ -32,26 +35,31 @@ class Notifications extends AbstractParser
*/
public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer)
{
if (empty($scopeSettings['notifications'])) {
return;
}
if (!empty($scopeSettings['notifications'])) {
$settings = $scopeSettings['notifications'];
$nodes = ['timeout'];

$settings = $scopeSettings['notifications'];
$nodes = ['timeout'];
foreach ($settings as $type => $config) {
foreach ($nodes as $key) {
if (!isset($config[$key]) || empty($config[$key])) {
continue;
}

foreach ($settings as $type => $config) {
foreach ($nodes as $key) {
if (!isset($config[$key]) || empty($config[$key])) {
continue;
$contextualizer->setContextualParameter(
sprintf('notifications.%s.%s', $type, $key),
$currentScope,
$config[$key]
);
}

$contextualizer->setContextualParameter(
sprintf('notifications.%s.%s', $type, $key),
$currentScope,
$config[$key]
);
}
}
if (!empty($scopeSettings['notification_count']) && !empty($scopeSettings['notification_count']['interval'])) {
$contextualizer->setContextualParameter(
'notification_count.interval',
$currentScope,
$scopeSettings['notification_count']['interval']
);
}
}

/**
Expand All @@ -70,6 +78,13 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder)
->end()
->end()
->end()
->end()
->arrayNode('notification_count')
->children()
->scalarNode('interval')
->info('Time in milliseconds between notification count refreshment.')
->end()
->end()
->end();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ parameters:
ibexa.site_access.config.admin_group.subtree_operations.copy_subtree.limit: 100

# Notifications
ibexa.site_access.config.admin_group.notifications.count.interval: 30000
ibexa.site_access.config.admin_group.notification_count.interval: 30000
ibexa.site_access.config.admin_group.notifications.error.timeout: 0
ibexa.site_access.config.admin_group.notifications.warning.timeout: 0
ibexa.site_access.config.admin_group.notifications.success.timeout: 5000
Expand Down

0 comments on commit 1608325

Please sign in to comment.