Adding the file for visitor pattern + function that need to be implemented.

This commit is contained in:
Lucas Silva
2023-05-05 10:38:19 +02:00
parent ef9e872394
commit 59cd8466be
5 changed files with 194 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Widget\Widgets;
use Chill\MainBundle\Widget\WidgetProviderInterface;
class WidgetBar implements WidgetProviderInterface
{
public function supports($data, $context): bool
{
// Check if the context is "bar"
return $context === 'bar';
}
public function getDataForWidget($data): array
{
// Process the data for the bar widget
// In this example, we assume the data is an array of numbers
$barData = $data['bar'];
// Return the widget data as an associative array
return [
'type' => 'bar',
'data' => $barData,
];
}
}