optimizely

IContentRepository vs IContentSoftLinkRepository in Optimizely


In Optimizely, I have come across 2 different interfaces to get a hold of the EPiServer repository - IContentRepository and IContentSoftLinkRepository

Example of IContentRepository :

 var repo = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<IContentRepository>();

and IContentSoftLinkRepository:

var linkRepository = ServiceLocator.Current.GetInstance<IContentSoftLinkRepository>();

Could somebody explain to me when to use one in front of the other? Thanks in advance.


Solution

  • IContentRepository allows you to get content (e.g. pages, blocks, media).

    IContentSoftLinkRepository allows you to retrieve soft links - i.e. links between content. For example, you can find all content items that link to some other content, such as pages that link to a specific document.