X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fforum%2Fsrc%2FPlugin%2FValidation%2FConstraint%2FForumLeafConstraintValidator.php;fp=web%2Fcore%2Fmodules%2Fforum%2Fsrc%2FPlugin%2FValidation%2FConstraint%2FForumLeafConstraintValidator.php;h=95603d8446b0e503970c5b9fd8046bb378a08564;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/core/modules/forum/src/Plugin/Validation/Constraint/ForumLeafConstraintValidator.php b/web/core/modules/forum/src/Plugin/Validation/Constraint/ForumLeafConstraintValidator.php new file mode 100644 index 000000000..95603d844 --- /dev/null +++ b/web/core/modules/forum/src/Plugin/Validation/Constraint/ForumLeafConstraintValidator.php @@ -0,0 +1,33 @@ +first(); + if (!isset($item)) { + return NULL; + } + + // Verify that a term has been selected. + if (!$item->entity) { + $this->context->addViolation($constraint->selectForum); + } + + // The forum_container flag must not be set. + if (!empty($item->entity->forum_container->value)) { + $this->context->addViolation($constraint->noLeafMessage, ['%forum' => $item->entity->getName()]); + } + } + +}