Skip to main content

Sitecore Explore Mode - ModuleManager

This post is an overview of the properties and methods of Sitecore Explore mode's ModuleManager class. It's part of an ongoing series taking a deep dive into this feature. For more general information on Explore Mode, read my introductory post.

Namespace: Sitecore.ExperienceExplorer.Business.Managers
Assembly: Sitecore.ExperienceExplorer.Business
Post written in reference to Sitecore 8.0 (rev. 141212)

ModuleManager is a broad helper class used widely throughout the Explore Mode codebase. In general, it's concerned with getting/setting key information about the current Session, User and state of the Explore Mode model.

GetSessionKey

This property returns the string "sitecore:experienceexplorer:currentmodel" with the value of the method GetSessionIdFromCookie() appeneded.

RealUserName

This property returns the value of the RealUserName property of the of the Model.

IsRealUserAdmin

This property returns the value of the IsRealUserAdmin property of the Model.

IsExpViewModeActive

If the value of sc_expview cookie is "1" then this property returns true, Otherwise it returns false.

BasePath

This property returns the current hostname of the current request including the scheme. It also appends the port number if it isn't 80.

Model  - Get

This property first checks to see if HttpContext.Current.Items contains an object with the key "ExperienceModel". If it does exist and is not null, then it's cast to ExperienceExplorerModel and returned.

If the HttpContext.Current.Items object did not exist or was null then HttpContext.Current.Application is checked to see if it contains an object with a key obtained from the GetSessionKey property. If it does, and the found object is not null then it's cast to ExperienceExplorerModel and returned.

If the HttpContext.Current.Application object did not exist or was null, then an a instance of ExperienceExplorerModel is obtained from its static GetDefaultPreset() method and returned.

Model - Set

The value passed to this property's setter is added to the following collections:

  • HttpContext.Current.Items (key "ExperienceModel"),
  • HttpContext.Current.Application (key obtained from the GetSessionKey property).

SetRealUser()

This method returns immediately if the current user is not authenticated. Otherwise, it performs the following actions:

  • Sets the RealUserName property of the Model from the context user's Name property.
  • Sets the IsRealUserAdmin property of the Model from the context user's IsAdministrator property.

Disable()

This method creates or updates the sc_expview cookie with the value "0".

Enable()

This method creates or updates the sc_expview cookie with the value "1".

GetSessionIdFromCookie()

If the ASP.NET_SessionId cookie is present, this method returns its value. Otherwise it returns an empty string.



Comments