Release 2.7.0 (#4506)
* added api URL for simpler integration * allow to request password change upon next login * make ModifiedAt timesheet independent * improved plugin api * replace kernel calls with AutoconfigureTag and TaggedIterator attributes * new translation keys (e.g. for days) * support setting min and max date on date and daterange pickers
This commit is contained in:
15
src/Doctrine/ModifiedAt.php
Normal file
15
src/Doctrine/ModifiedAt.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?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\Doctrine;
|
||||
|
||||
interface ModifiedAt
|
||||
{
|
||||
public function setModifiedAt(\DateTimeImmutable $dateTime): void;
|
||||
}
|
||||
@@ -9,14 +9,13 @@
|
||||
|
||||
namespace App\Doctrine;
|
||||
|
||||
use App\Entity\Timesheet;
|
||||
use Doctrine\Bundle\DoctrineBundle\Attribute\AsDoctrineListener;
|
||||
use Doctrine\Common\EventSubscriber;
|
||||
use Doctrine\ORM\Event\OnFlushEventArgs;
|
||||
use Doctrine\ORM\Events;
|
||||
|
||||
/**
|
||||
* Automatically set the modifiedAt field for all Timesheet entries.
|
||||
* Automatically set the modifiedAt field for all ModifiedAt instances.
|
||||
*/
|
||||
#[AsDoctrineListener(event: Events::onFlush, priority: 60)]
|
||||
final class ModifiedSubscriber implements EventSubscriber, DataSubscriberInterface
|
||||
@@ -34,17 +33,15 @@ final class ModifiedSubscriber implements EventSubscriber, DataSubscriberInterfa
|
||||
$now = new \DateTimeImmutable('now', new \DateTimeZone('UTC'));
|
||||
|
||||
foreach ($uow->getScheduledEntityUpdates() as $entity) {
|
||||
if (!($entity instanceof Timesheet)) {
|
||||
continue;
|
||||
if ($entity instanceof ModifiedAt) {
|
||||
$entity->setModifiedAt($now);
|
||||
}
|
||||
$entity->setModifiedAt($now);
|
||||
}
|
||||
|
||||
foreach ($uow->getScheduledEntityInsertions() as $entity) {
|
||||
if (!($entity instanceof Timesheet)) {
|
||||
continue;
|
||||
if ($entity instanceof ModifiedAt) {
|
||||
$entity->setModifiedAt($now);
|
||||
}
|
||||
$entity->setModifiedAt($now);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,12 @@ use Doctrine\Bundle\DoctrineBundle\Attribute\AsDoctrineListener;
|
||||
use Doctrine\Common\EventSubscriber;
|
||||
use Doctrine\ORM\Event\OnFlushEventArgs;
|
||||
use Doctrine\ORM\Events;
|
||||
use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
|
||||
|
||||
/**
|
||||
* A listener to make sure all Timesheet entries will be calculated properly (e.g. duration and rates).
|
||||
* A listener to make sure all Timesheet entries will be calculated properly.
|
||||
*
|
||||
* E.g. updates timesheet records and applies configured rate & rounding rules.
|
||||
*/
|
||||
#[AsDoctrineListener(event: Events::onFlush, priority: 50)]
|
||||
final class TimesheetSubscriber implements EventSubscriber, DataSubscriberInterface
|
||||
@@ -30,7 +33,10 @@ final class TimesheetSubscriber implements EventSubscriber, DataSubscriberInterf
|
||||
/**
|
||||
* @param CalculatorInterface[] $calculators
|
||||
*/
|
||||
public function __construct(private iterable $calculators)
|
||||
public function __construct(
|
||||
#[TaggedIterator(CalculatorInterface::class)]
|
||||
private readonly iterable $calculators
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user