protected function assertEntityIsValid($entity, $scope = null)
    {
        if (!$this->validator) {
            throw new \BadMethodCallException(sprintf(
                'Method %s() cannot be used while validator is not configured.',
                __METHOD__
            ));
        }

        $scopes = $scope ? (array) $scope : null;

        $violationList = $this->validator->validate(
            $entity,
            null,
            $scopes
        );

        if (!count($violationList)) {
            return;
        }

        throw new ValidationException($entity, $violationList, $scopes);
    }