Does the namespace, class name and naming convention work like it does for modules?
These links don't seem to mention it:
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityDoes the namespace, class name and naming convention work like it does for modules?
These links don't seem to mention it:
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
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.