Typehint interface in stead of concrete class

Created on 11 December 2019, almost 6 years ago
Updated 19 August 2025, about 1 month ago

Problem/Motivation

The constructor of the Permissions class currently requires the second parameter to be an instance of a TranslationManager class. However, in general, you should aim to program against an interface and not a concrete class (i.e not violating the dependency inversion principle). Because of this, possible other implementations of a TranslationManager (added by other modules) will cause this to fail.

Proposed resolution

In stead of type hinting the concrete class used, we should use an interface as type-hint (following the dependency inversion principle). In this case that would be the TranslationInterface.

Remaining tasks


- Review patch

User interface changes

None

API changes

See proposed resolution. This should not break existing implementations, as they all will comply to the TranslationInterface. However, this will allow other implementations of the TranslationInterface to be used as well.

Data model changes

See proposed resolution. This should not break existing implementations.

🐛 Bug report
Status

Needs work

Version

2.0

Component

Miscellaneous

Created by

🇳🇱Netherlands Dimiter

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024