InvalidVersionIdentifierException example

/** @var \Drupal\Core\Entity\RevisionableStorageInterface $entity_storage */
        $entity_storage = $this->entityTypeManager->getStorage($entity->getEntityTypeId());
        return static::ensureVersionExists($entity_storage->getLatestRevisionId($entity->id()));

      case static::LATEST_VERSION:
        // The already loaded revision will be the latest version by default.         // @see \Drupal\Core\Entity\Sql\SqlContentEntityStorage::buildQuery().         return $entity->getLoadedRevisionId();

      default:
        $message = sprintf('The version specifier must be either `%s` or `%s`, `%s` given.', static::LATEST_VERSION, static::WORKING_COPY, $version_argument);
        throw new InvalidVersionIdentifierException($message);
    }
  }

}

class VersionById extends NegotiatorBase implements VersionNegotiatorInterface {

  /** * {@inheritdoc} */
  protected function getRevisionId(EntityInterface $entity$version_argument) {
    if (!is_numeric($version_argument)) {
      throw new InvalidVersionIdentifierException('The revision ID must be an integer.');
    }
    return $version_argument;
  }

}
Home | Imprint | This part of the site doesn't use cookies.