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:
@@ -9,11 +9,13 @@
|
||||
|
||||
namespace App\Validator\Constraints;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
|
||||
/**
|
||||
* Extend this class if you want to add dynamic project validation (eg. via a bundle).
|
||||
*/
|
||||
#[AutoconfigureTag]
|
||||
abstract class ProjectConstraint extends Constraint
|
||||
{
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
namespace App\Validator\Constraints;
|
||||
|
||||
use App\Entity\Project;
|
||||
use App\Validator\Constraints\Project as ProjectConstraint;
|
||||
use App\Validator\Constraints\Project as ProjectEntityConstraint;
|
||||
use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\ConstraintValidator;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
@@ -19,9 +20,12 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
final class ProjectValidator extends ConstraintValidator
|
||||
{
|
||||
/**
|
||||
* @param Constraint[] $constraints
|
||||
* @param ProjectConstraint[] $constraints
|
||||
*/
|
||||
public function __construct(private iterable $constraints = [])
|
||||
public function __construct(
|
||||
#[TaggedIterator(ProjectConstraint::class)]
|
||||
private iterable $constraints = []
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -31,8 +35,8 @@ final class ProjectValidator extends ConstraintValidator
|
||||
*/
|
||||
public function validate(mixed $value, Constraint $constraint): void
|
||||
{
|
||||
if (!($constraint instanceof ProjectConstraint)) {
|
||||
throw new UnexpectedTypeException($constraint, ProjectConstraint::class);
|
||||
if (!($constraint instanceof ProjectEntityConstraint)) {
|
||||
throw new UnexpectedTypeException($constraint, ProjectEntityConstraint::class);
|
||||
}
|
||||
|
||||
if (!\is_object($value) || !($value instanceof Project)) {
|
||||
@@ -52,10 +56,10 @@ final class ProjectValidator extends ConstraintValidator
|
||||
protected function validateProject(Project $project, ExecutionContextInterface $context): void
|
||||
{
|
||||
if (null !== $project->getStart() && null !== $project->getEnd() && $project->getStart()->getTimestamp() > $project->getEnd()->getTimestamp()) {
|
||||
$context->buildViolation(ProjectConstraint::getErrorName(ProjectConstraint::END_BEFORE_BEGIN_ERROR))
|
||||
$context->buildViolation(ProjectEntityConstraint::getErrorName(ProjectEntityConstraint::END_BEFORE_BEGIN_ERROR))
|
||||
->atPath('end')
|
||||
->setTranslationDomain('validators')
|
||||
->setCode(ProjectConstraint::END_BEFORE_BEGIN_ERROR)
|
||||
->setCode(ProjectEntityConstraint::END_BEFORE_BEGIN_ERROR)
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace App\Validator\Constraints;
|
||||
|
||||
use App\Entity\Timesheet as TimesheetEntity;
|
||||
use App\Validator\Constraints\QuickEntryTimesheet as QuickEntryTimesheetConstraint;
|
||||
use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\ConstraintValidator;
|
||||
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
@@ -18,9 +19,12 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
final class QuickEntryTimesheetValidator extends ConstraintValidator
|
||||
{
|
||||
/**
|
||||
* @param Constraint[] $constraints
|
||||
* @param TimesheetConstraint[] $constraints
|
||||
*/
|
||||
public function __construct(private iterable $constraints)
|
||||
public function __construct(
|
||||
#[TaggedIterator(TimesheetConstraint::class)]
|
||||
private iterable $constraints
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -9,11 +9,13 @@
|
||||
|
||||
namespace App\Validator\Constraints;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
|
||||
/**
|
||||
* Extend this class if you want to add dynamic timesheet validation (eg. via a bundle).
|
||||
*/
|
||||
#[AutoconfigureTag]
|
||||
abstract class TimesheetConstraint extends Constraint
|
||||
{
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
namespace App\Validator\Constraints;
|
||||
|
||||
use App\Entity\Timesheet as TimesheetEntity;
|
||||
use App\Validator\Constraints\Timesheet as TimesheetConstraint;
|
||||
use App\Validator\Constraints\Timesheet as TimesheetEntityConstraint;
|
||||
use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\ConstraintValidator;
|
||||
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
@@ -18,9 +19,12 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
final class TimesheetValidator extends ConstraintValidator
|
||||
{
|
||||
/**
|
||||
* @param Constraint[] $constraints
|
||||
* @param TimesheetConstraint[] $constraints
|
||||
*/
|
||||
public function __construct(private iterable $constraints)
|
||||
public function __construct(
|
||||
#[TaggedIterator(TimesheetConstraint::class)]
|
||||
private iterable $constraints
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -30,8 +34,8 @@ final class TimesheetValidator extends ConstraintValidator
|
||||
*/
|
||||
public function validate(mixed $timesheet, Constraint $constraint): void
|
||||
{
|
||||
if (!($constraint instanceof TimesheetConstraint)) {
|
||||
throw new UnexpectedTypeException($constraint, Timesheet::class);
|
||||
if (!($constraint instanceof TimesheetEntityConstraint)) {
|
||||
throw new UnexpectedTypeException($constraint, TimesheetEntityConstraint::class);
|
||||
}
|
||||
|
||||
if (!\is_object($timesheet) || !($timesheet instanceof TimesheetEntity)) {
|
||||
|
||||
Reference in New Issue
Block a user