Release 2.0.27 (#4107)
This commit is contained in:
@@ -13,17 +13,17 @@ use App\Entity\User;
|
||||
|
||||
/**
|
||||
* This event is triggered for every action:
|
||||
* - once per side load for table actions
|
||||
* - once for every row item
|
||||
* - once per side load for page actions
|
||||
* - once for every entity item (table row)
|
||||
*
|
||||
* @property array{'actions': array, 'view': string} $payload
|
||||
*/
|
||||
class PageActionsEvent extends ThemeEvent
|
||||
{
|
||||
private string $action;
|
||||
private string $view;
|
||||
private int $divider = 0;
|
||||
private ?string $locale = null;
|
||||
|
||||
public function __construct(User $user, array $payload, string $action, string $view)
|
||||
public function __construct(User $user, array $payload, private string $action, private string $view)
|
||||
{
|
||||
// only for BC reasons, do not access it directly!
|
||||
if (!\array_key_exists('actions', $payload)) {
|
||||
@@ -34,8 +34,6 @@ class PageActionsEvent extends ThemeEvent
|
||||
$payload['view'] = $view;
|
||||
}
|
||||
parent::__construct($user, $payload);
|
||||
$this->action = $action;
|
||||
$this->view = $view;
|
||||
}
|
||||
|
||||
public function getActionName(): string
|
||||
@@ -101,7 +99,7 @@ class PageActionsEvent extends ThemeEvent
|
||||
|
||||
public function hasSubmenu(string $submenu): bool
|
||||
{
|
||||
if (!\array_key_exists($submenu, $this->payload['actions'])) {
|
||||
if (!$this->hasAction($submenu)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -110,7 +108,7 @@ class PageActionsEvent extends ThemeEvent
|
||||
|
||||
public function addActionToSubmenu(string $submenu, string $key, array $action): void
|
||||
{
|
||||
if (\array_key_exists($submenu, $this->payload['actions'])) {
|
||||
if ($this->hasAction($submenu)) {
|
||||
if (!\array_key_exists('children', $this->payload['actions'][$submenu])) {
|
||||
$this->payload['actions'][$submenu]['children'] = [];
|
||||
}
|
||||
@@ -125,14 +123,14 @@ class PageActionsEvent extends ThemeEvent
|
||||
|
||||
public function addAction(string $key, array $action): void
|
||||
{
|
||||
if (!\array_key_exists($key, $this->payload['actions'])) {
|
||||
if (!$this->hasAction($key)) {
|
||||
$this->payload['actions'][$key] = $action;
|
||||
}
|
||||
}
|
||||
|
||||
public function removeAction(string $key): void
|
||||
{
|
||||
if (\array_key_exists($key, $this->payload['actions'])) {
|
||||
if ($this->hasAction($key)) {
|
||||
unset($this->payload['actions'][$key]);
|
||||
}
|
||||
}
|
||||
@@ -153,6 +151,11 @@ class PageActionsEvent extends ThemeEvent
|
||||
$this->addAction('create', ['url' => $url, 'class' => ($modal ? 'modal-ajax-form' : ''), 'title' => 'create', 'accesskey' => 'a']);
|
||||
}
|
||||
|
||||
public function addEdit(string $url, bool $modal = true): void
|
||||
{
|
||||
$this->addAction('edit', ['url' => $url, 'class' => ($modal ? 'modal-ajax-form' : ''), 'translation_domain' => 'actions', 'title' => 'edit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Link to a configuration section.
|
||||
*
|
||||
|
||||
@@ -16,9 +16,9 @@ use Symfony\Contracts\EventDispatcher\Event;
|
||||
final class ReportingEvent extends Event
|
||||
{
|
||||
/**
|
||||
* @var ReportInterface[]
|
||||
* @var array<string, ReportInterface>
|
||||
*/
|
||||
private $reports = [];
|
||||
private array $reports = [];
|
||||
|
||||
public function __construct(private User $user)
|
||||
{
|
||||
@@ -37,7 +37,7 @@ final class ReportingEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ReportInterface[]
|
||||
* @return array<ReportInterface>
|
||||
*/
|
||||
public function getReports(): array
|
||||
{
|
||||
|
||||
@@ -23,11 +23,12 @@ class ThemeEvent extends Event
|
||||
public const CONTENT_AFTER = 'app.theme.content_after';
|
||||
|
||||
private string $content = '';
|
||||
protected mixed $payload;
|
||||
|
||||
public function __construct(private ?User $user = null, mixed $payload = null)
|
||||
/**
|
||||
* @param array<string, mixed|array<mixed>> $payload
|
||||
*/
|
||||
public function __construct(private ?User $user = null, protected array $payload = [])
|
||||
{
|
||||
$this->payload = $payload;
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
@@ -47,18 +48,11 @@ class ThemeEvent extends Event
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPayload(): mixed
|
||||
/**
|
||||
* @return array<string, mixed|array<mixed>>
|
||||
*/
|
||||
public function getPayload(): array
|
||||
{
|
||||
return $this->payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since 2.0.19, will be removed with 2.1
|
||||
*/
|
||||
public function setPayload(mixed $payload): void
|
||||
{
|
||||
@trigger_error('ThemeEvent::setPayload() is deprecated, use AbstractActionsSubscriber instead.', E_USER_DEPRECATED);
|
||||
|
||||
$this->payload = $payload;
|
||||
}
|
||||
}
|
||||
|
||||
41
src/Event/WorkingTimeApproveMonthEvent.php
Normal file
41
src/Event/WorkingTimeApproveMonthEvent.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?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\Event;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\WorkingTime\Model\Month;
|
||||
use Symfony\Contracts\EventDispatcher\Event;
|
||||
|
||||
final class WorkingTimeApproveMonthEvent extends Event
|
||||
{
|
||||
public function __construct(private User $user, private Month $month, private \DateTimeInterface $approvalDate, private User $approver)
|
||||
{
|
||||
}
|
||||
|
||||
public function getUser(): User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function getMonth(): Month
|
||||
{
|
||||
return $this->month;
|
||||
}
|
||||
|
||||
public function getApprovalDate(): \DateTimeInterface
|
||||
{
|
||||
return $this->approvalDate;
|
||||
}
|
||||
|
||||
public function getApprover(): User
|
||||
{
|
||||
return $this->approver;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user