Feature #31261

Virtual objects - generate proxy classes for interfaces

Added by Christopher Hlubek almost 10 years ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Object
Target version:
-
Start date:
2011-10-25
Due date:
% Done:

0%

Estimated time:
PHP Version:
Has patch:
No
Complexity:

Description

It should be possible to declare an interface and configure an object (e.g. singleton based on a prototype with arguments) for it in Objects.yaml. Right now you have to write a factory class to have different singletons based on the same prototype object.

Example:

Objects.yaml


TYPO3\Example\MyInterface:
  scope: singleton
  className: TYPO3\Example\MyClass # <- scope: prototype
  arguments:
    1:
      value: Foo

TYPO3\Example\MyDebugInterface:
  scope: singleton
  className: TYPO3\Example\MyClass # <- scope: prototype
  arguments:
    1:
      value: Bar
  properties:
    debug:
      value: true

There should be a generated proxy class for the interface that implements the interface. Dependency injection with the interface type should work with that automatically.

I think instantiating the interface with new \TYPO3\Example\MyInterface() has not to work since it's also contra-intuitive to the default PHP behaviour. So DI or the ObjectManager must be used for that.

No data to display

Also available in: Atom PDF