in modules/quanthub_book/src/Plugin/Validation/Constraint/QuanthubBookRequiredConstraintValidator.php [45:67]
public function validate($entity, Constraint $constraint) {
if ($entity->bundle() == 'book') {
if ($entity->book['bid'] == 'new') {
// Nothing to do here. This page will be title of new book.
}
else {
if ($entity->book['bid'] == 0) {
// Book entity is not set.
$this->context->buildViolation($constraint->messageBookNotExist)
->atPath('book.pid')
->setInvalidValue($entity)
->addViolation();
}
elseif (!in_array($entity->book['bid'], array_keys($this->bookManager->getAllBooks()))) {
// Book entity is set. But not exist in list of all books entities.
$this->context->buildViolation($constraint->messageBookInvalid)
->atPath('book.pid')
->setInvalidValue($entity)
->addViolation();
}
}
}
}