3

Does the namespace, class name and naming convention work like it does for modules?

These links don't seem to mention it:

4
  • I believe it should but looking at bootstrap they seem to be needing a fix git.drupalcode.org/project/bootstrap/blob/8.x-3.x/…
    – GiorgosK
    Apr 16, 2019 at 4:28
  • 2
    It's not available by default, and from a logical standpoint, usually shoudln't be necessary, as the theme layer is for theming things.
    – Jaypan
    Apr 16, 2019 at 4:39
  • Thanks @giorgosk ! It appears to work OOTB, using composer drupal-project install. Autoload fix be might needed though for batch and ajax callbacks though as noted in bootstrap theme. Feel free to add answer. Apr 16, 2019 at 5:27
  • 2
    This depends on what you want to load, you can't use plugins or container services for example.
    – 4uk4
    Apr 16, 2019 at 8:03

2 Answers 2

1

I believe it should but looking at bootstrap they seem to be needing a fix https://git.drupalcode.org/project/bootstrap/blob/8.x-3.x/autoload-fix.php

0
5

There's an interesting development going on regarding themes and OOP. Look at Allow themes to provide services.yml which finally got closed as Won't Fix. From Mark Carver's closing comment:

I really don't think we should be opening up themes to services anymore.

A lot has changed (for the better) in the 5 years I've been following this issue (closely).

If this were to happen... there wouldn't be any real delineation between what a module is vs. what theme is, would there?

Instead as a result Allow themes to declare dependencies on modules is the route to go now. To move all the OOP stuff out of themes as the theme layer is for theming things, as JayPan said in the comments.

My answer to that problem is that I now always create a themename_companion module where I provide Drush 9 commands, helper functions, services etc. for my themes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.