Add new comment

Posted on by Katherine Bailey.

Hi Ryan,
that is a great question. So, one area I didn't touch on at all in this post is the Dependency Injection Container. That's what is used in core to inject dependencies. Briefly, you provide configuration in the form of "service definitions" that tell the container what to actually inject when instantiating the class. What doesn't come through in the example above, because I was keeping it simple for the purpose of making the point about loose coupling, is that the SubPathAuto class would actually be a service itself, with a definition along the lines of

  class: Drupal\subpathauto\SubPathAuto
  arguments: ['@path_processor_alias']

telling the container to inject the existing 'path_processor_alias' service when intantiating the SubPathAuto class.
And since all service definitions can be altered by any module, you could have another module alter this and specify something else to pass in.
Here are the symfony docs explaining how the DI container works http :// It is also covered in the DrupalCon Portland talk I linked to at the start of this post.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.

Filtered HTML

  • Use [acphone_sales], [acphone_sales_text], [acphone_support], [acphone_international], [acphone_devcloud], [acphone_extra1] and [acphone_extra2] as placeholders for Acquia phone numbers. Add class "acquia-phones-link" to wrapper element to make number a link.
  • To post pieces of code, surround them with <code>...</code> tags. For PHP code, you can use <?php ... ?>, which will also colour it based on syntax.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <h4> <h5> <h2> <img>
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.