Fixed some inspection issues.

This commit is contained in:
Jan Böhmer 2020-08-21 22:43:37 +02:00
parent 6caf605fe2
commit e01b06fb85
80 changed files with 173 additions and 218 deletions

View file

@ -88,12 +88,14 @@ class NoLockoutValidator extends ConstraintValidator
$user = $this->entityManager->getRepository(User::class)->getAnonymousUser();
}
if ($user instanceof User) {
//Check if we the change_permission permission has changed from allow to disallow
if (false === ($this->resolver->inherit($user, 'users', 'edit_permissions') ?? false)) {
$this->context->addViolation($constraint->message);
}
}
//Check if we the change_permission permission has changed from allow to disallow
if (($user instanceof User) && false === ($this->resolver->inherit(
$user,
'users',
'edit_permissions'
) ?? false)) {
$this->context->addViolation($constraint->message);
}
}
}
}

View file

@ -60,9 +60,4 @@ class NoneOfItsChildren extends Constraint
* @var string The message used if it is tried to use one of the children for as parent
*/
public $children_message = 'validator.noneofitschild.children';
public function validatedBy()
{
return parent::validatedBy(); // TODO: Change the autogenerated stub
}
}

View file

@ -57,7 +57,7 @@ class SelectableValidator extends ConstraintValidator
* Checks if the passed value is valid.
*
* @param mixed $value The value that should be validated
* @param \Symfony\Component\Validator\Constraint $constraint The constraint for the validation
* @param Constraint $constraint The constraint for the validation
*/
public function validate($value, Constraint $constraint): void
{

View file

@ -104,20 +104,18 @@ class ValidPartLotValidator extends ConstraintValidator
}
//Check for onlyExisting
if ($value->getStorageLocation()->isLimitToExistingParts()) {
if (!$parts->contains($value->getPart())) {
$this->context->buildViolation('validator.part_lot.only_existing')
->atPath('storage_location')->addViolation();
}
if ($value->getStorageLocation()->isLimitToExistingParts() && !$parts->contains($value->getPart())) {
$this->context->buildViolation('validator.part_lot.only_existing')
->atPath('storage_location')->addViolation();
}
//Check for only single part
if ($value->getStorageLocation()->isOnlySinglePart()) {
if (($parts->count() > 0) && !$parts->contains($value->getPart())) {
if ($value->getStorageLocation()->isOnlySinglePart() && ($parts->count() > 0) && !$parts->contains(
$value->getPart()
)) {
$this->context->buildViolation('validator.part_lot.single_part')
->atPath('storage_location')->addViolation();
}
}
}
}
}