Skip to content

Commit

Permalink
Fixed Menuboard | Renaming a Category does not update in CMS Layout E…
Browse files Browse the repository at this point in the history
…ditor (#2938)
  • Loading branch information
mgbaybay authored Mar 7, 2025
1 parent 00cc99d commit 3a763be
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/Controller/MenuBoardCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ public function add(Request $request, Response $response, $id): Response

$menuBoardCategory = $this->menuBoardCategoryFactory->create($id, $name, $mediaId, $code, $description);
$menuBoardCategory->save();
$menuBoard->save(['audit' => false]);

// Return
$this->getState()->hydrate([
Expand Down Expand Up @@ -430,6 +431,7 @@ public function edit(Request $request, Response $response, $id): Response
$menuBoardCategory->code = $sanitizedParams->getString('code');
$menuBoardCategory->description = $sanitizedParams->getString('description');
$menuBoardCategory->save();
$menuBoard->save();

// Success
$this->getState()->hydrate([
Expand Down
5 changes: 4 additions & 1 deletion lib/Entity/MenuBoard.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,12 @@ public function save($options = [])
{
$options = array_merge([
'validate' => true,
'audit' => true
], $options);

$this->getLog()->debug('Saving ' . $this);
if ($options['audit']) {
$this->getLog()->debug('Saving ' . $this);
}

if ($options['validate']) {
$this->validate();
Expand Down
13 changes: 13 additions & 0 deletions lib/Widget/MenuBoardCategoryProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

use Carbon\Carbon;
use Xibo\Event\MenuBoardCategoryRequest;
use Xibo\Event\MenuBoardModifiedDtRequest;
use Xibo\Widget\Provider\DataProviderInterface;
use Xibo\Widget\Provider\DurationProviderInterface;
use Xibo\Widget\Provider\WidgetProviderInterface;
Expand Down Expand Up @@ -55,6 +56,18 @@ public function getDataCacheKey(DataProviderInterface $dataProvider): ?string

public function getDataModifiedDt(DataProviderInterface $dataProvider): ?Carbon
{
$this->getLog()->debug('fetchData: MenuBoardCategoryProvider passing to modifiedDt request event');

$menuId = $dataProvider->getProperty('menuId');

if ($menuId !== null) {
// Raise an event to get the modifiedDt of this dataSet
$event = new MenuBoardModifiedDtRequest($menuId);
$this->getDispatcher()->dispatch($event, MenuBoardModifiedDtRequest::$NAME);

return max($event->getModifiedDt(), $dataProvider->getWidgetModifiedDt());
}

return null;
}
}

0 comments on commit 3a763be

Please sign in to comment.