ModelBundle/Validator/Constraints/PreventProhibitedStatusChangeValidator.php
public function validate($value, Constraint $constraint)
    {
        if (!$value instanceof StatusableInterface) {
            return;
        }

        $originalDoc = $this->objectManager->getUnitOfWork()->getOriginalDocumentData($value);
        if (empty($originalDoc)) {
            return;
        }

        $status = $value->getStatus();
        $oldStatus = $originalDoc['status'];

        if (!$status instanceof StatusInterface || !$oldStatus instanceof StatusInterface) {
            return;
        }

        if ($oldStatus->getId() === $status->getId()) {
            return;
        }

        $oldNode = clone $value;
        $this->objectManager->detach($oldNode);
        $oldNode->setStatus($originalDoc['status']);

        if (!$this->authorizationChecker->isGranted($status, $oldNode)) {
            $this->context->buildViolation($constraint->message)
                ->atPath('status')
                ->addViolation();
        }
    }
public function validate($value, Constraint $constraint)
    {
        if (!$value instanceof StatusableInterface) {
            return;
        }

        $originalDoc = $this->objectManager->getUnitOfWork()->getOriginalDocumentData($value);
        if (empty($originalDoc)) {
            return;
        }

        $status = $value->getStatus();
        $oldStatus = $originalDoc['status'];

        if (!$status instanceof StatusInterface || !$oldStatus instanceof StatusInterface) {
            return;
        }

        if ($oldStatus->getId() === $status->getId()) {
            return;
        }

        $oldNode = clone $value;
        $this->objectManager->detach($oldNode);
        $oldNode->setStatus($originalDoc['status']);

        if (!$this->authorizationChecker->isGranted($status, $oldNode)) {
            $this->context->buildViolation($constraint->message)
                ->atPath('status')
                ->addViolation();
        }
    }
Checks if the passed value is valid.

@param mixed      $value      The value that should be validated
@param Constraint $constraint The constraint for the validation