Protect some services from being referenced from outside container

Created on 4 October 2014, over 10 years ago
Updated 9 January 2025, 3 months ago

Problem/Motivation

Services can be declared as non public in their definition. A service marked like this cannot be accessed with $container->get('service-id');, rather it can only be referenced from other services. Also note that...

If you use a private service as an argument to only one other service, this will result in an inlined instantiation (e.g. new PrivateFooBar()) inside this other service, making it publicly unavailable at runtime.

Proposed resolution

  1. Determine whether inlining of non-public services results in substantial performance gains.
  2. Agree on a policy defining which service classes should be marked non-public. Document that policy.
  3. Go through all service definitions and apply the policy.

Remaining tasks

User interface changes

API changes

πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component

base system

Created by

πŸ‡¨πŸ‡­Switzerland znerol

Live updates comments and jobs are added and updated live.
  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

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