Skip to content

Finish Dependency Injection Support for PortalController #3934

Description

@SkyeHoefling

Description of problem

Since support has been stabilized for Dependency Injection the goal is to add better support across the different static APIs. The PortalController current supports Dependency Injection via IPortalController however many APIs are missing because they are static APIs.

For example: If you need to decrypt portal settings you would use the following API

PortalController.GetEncryptedString(string settingName, int portalID, string passPhrase);

There is no instance level API method that supports this, which makes it difficult to use with Dependency Injection.

Description of solution

Create a copy of every static API in the PortalController for the IPortalController. Then mark the existing static API obsolete while using the new instance version.

If we were to use the example above with GetEncryptedString. Move the declaration to the IPortalController.

public interface IPortalController
{
    string GetEncryptedString(string settingName, int portalID, string passPhrase);    

    // omitted code

Then update the PortalController code to have both

public class PortalController
{
    [Obsolete("Deprecated in DNN 9.7.0. Use the 'IPortalController.GetEncryptedString' instnace method. Scheduled removal in v11.0.0.")]
    public static string GetEncryptedString(string settingName, int portalID, string passPhrase) =>
        GetEncryptedString(settingName, portalID, passPhrase);

    string IPortalController.GetEncryptedString(string settingName, int portalID, string passPhrase)
    {
        // omitted code
    }
}

Description of alternatives considered

N/A

Screenshots

N/A

Additional context

This change will effect the entire platform

Affected browser

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions