This class caches the information about the content types on the H5P Hub.

IT DOES NOT exactly correspond to the ContentTypeCache of the original PHP implementation, as it only caches the data (and converts it to a local format). It DOES NOT add information about locally installed libraries and user rights. ContentTypeInformationRepository is meant to do this.

Usage:

  • Get the content type information by calling get().
  • The method updateIfNecessary() should be called regularly, e.g. through a cron-job.
  • Use contentTypeCacheRefreshInterval in the IH5PConfig object to set how often the update should be performed. You can also use forceUpdate() if you want to bypass the interval.

Constructors

Methods

  • Downloads information about available content types from the H5P Hub. This method will create a UUID to identify this site if required.

    Returns Promise<any[]>

    content types

  • Downloads the content type information from the H5P Hub and stores it in the storage object.

    Returns Promise<any>

    the downloaded (and saved) cache; undefined if it failed (e.g. because Hub was unreachable)

  • Returns the cache data.

    Parameters

    • ...machineNames: string[]

      (optional) The method only returns content type cache data for these machine names.

    Returns Promise<IHubContentType[]>

    Cached hub data in a format in which the version objects are flattened into the main object,

  • Returns the date and time of the last update of the cache.

    Returns Promise<Date>

    the date and time; undefined if the cache was never updated before.

  • If the running site has already been registered at the H5P hub, this method will return the UUID of it. If it hasn't been registered yet, it will do so and store the UUID in the storage object.

    Returns Promise<string>

    uuid

  • Checks if the interval between updates has been exceeded and updates the cache if necessary.

    Returns Promise<boolean>

    true if cache was updated, false if not