refactored page actions to event subscriber (#2420)
This commit is contained in:
@@ -36,6 +36,7 @@ final class IconExtension extends AbstractExtension
|
||||
'dashboard' => 'fas fa-tachometer-alt',
|
||||
'debug' => 'far fa-file-alt',
|
||||
'delete' => 'far fa-trash-alt',
|
||||
'details' => 'fas fa-info-circle',
|
||||
'doctor' => 'fas fa-medkit',
|
||||
'dot' => 'fas fa-circle',
|
||||
'download' => 'fas fa-download',
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Kimai time-tracking app.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace App\Twig\Runtime;
|
||||
|
||||
use App\Export\ServiceExport;
|
||||
use Twig\Extension\RuntimeExtensionInterface;
|
||||
|
||||
final class ExporterExtension implements RuntimeExtensionInterface
|
||||
{
|
||||
/**
|
||||
* @var ServiceExport
|
||||
*/
|
||||
private $service;
|
||||
|
||||
public function __construct(ServiceExport $service)
|
||||
{
|
||||
$this->service = $service;
|
||||
}
|
||||
|
||||
public function getTimesheetExporter(): array
|
||||
{
|
||||
$ids = [];
|
||||
foreach ($this->service->getTimesheetExporter() as $exporter) {
|
||||
$ids[] = $exporter->getId();
|
||||
}
|
||||
|
||||
return $ids;
|
||||
}
|
||||
}
|
||||
@@ -52,13 +52,9 @@ final class ThemeExtension implements RuntimeExtensionInterface
|
||||
return $themeEvent;
|
||||
}
|
||||
|
||||
public function actions(User $user, string $action, array $payload): ThemeEvent
|
||||
public function actions(User $user, string $action, string $view, array $payload = []): ThemeEvent
|
||||
{
|
||||
if (!\array_key_exists('actions', $payload)) {
|
||||
$payload['actions'] = [];
|
||||
}
|
||||
|
||||
$themeEvent = new PageActionsEvent($user, $payload, $action);
|
||||
$themeEvent = new PageActionsEvent($user, $payload, $action, $view);
|
||||
|
||||
$eventName = 'actions.' . $action;
|
||||
|
||||
|
||||
@@ -10,9 +10,7 @@
|
||||
namespace App\Twig;
|
||||
|
||||
use App\Twig\Runtime\EncoreExtension;
|
||||
use App\Twig\Runtime\ExporterExtension;
|
||||
use App\Twig\Runtime\MarkdownExtension;
|
||||
use App\Twig\Runtime\ReportingExtension;
|
||||
use App\Twig\Runtime\ThemeExtension;
|
||||
use App\Twig\Runtime\TimesheetExtension;
|
||||
use App\Twig\Runtime\WidgetExtension;
|
||||
@@ -31,11 +29,9 @@ class RuntimeExtensions extends AbstractExtension
|
||||
new TwigFunction('trigger', [ThemeExtension::class, 'trigger'], ['needs_environment' => true]),
|
||||
new TwigFunction('actions', [ThemeExtension::class, 'actions']),
|
||||
new TwigFunction('javascript_translations', [ThemeExtension::class, 'getJavascriptTranslations']),
|
||||
new TwigFunction('timesheet_exporter', [ExporterExtension::class, 'getTimesheetExporter']),
|
||||
new TwigFunction('active_timesheets', [TimesheetExtension::class, 'activeEntries']),
|
||||
new TwigFunction('encore_entry_css_source', [EncoreExtension::class, 'getEncoreEntryCssSource']),
|
||||
new TwigFunction('render_widget', [WidgetExtension::class, 'renderWidget'], ['is_safe' => ['html']]),
|
||||
new TwigFunction('available_reports', [ReportingExtension::class, 'getAvailableReports'], []),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user