Factories and dependency injection

Last week I wrote about dependency injection anti-patterns in Drupal. These anti-patterns occur when your service's constructor has logic that interacts with the injected dependent services beyond assigning them to properties. These anti-patterns include creating a new object from a factory or retrieving an object from a stack. However, Symfony's service container supports defining services built from factories. This can streamline your code and follow best practices when using dependency injection.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • Symfony
  • ethstaker
  • DreamBathrooms
  • cubers
  • magazineikmin
  • InstantRegret
  • GTA5RPClips
  • thenastyranch
  • Youngstown
  • rosin
  • slotface
  • osvaldo12
  • ngwrru68w68
  • kavyap
  • everett
  • JUstTest
  • Durango
  • Leos
  • cisconetworking
  • mdbf
  • khanakhh
  • normalnudes
  • tester
  • modclub
  • anitta
  • tacticalgear
  • megavids
  • provamag3
  • lostlight
  • All magazines