I created a custom D8 module in:
In that custom module are
I wrote some custom code in my custom theme in
My namespaces are:
I can add/use MyClass in MySubscriber.php (
use Drupal\mytheme\MyClass) and it works fine.
However, when trying to add MyClass to MyController.php, it creates a PHP error claiming that it cannot find MyClass. The MyClass code is identical between the two module files.
Why won't it work in MyController.php while working fine in MySubscriber.php?
I've tried a lot of testing, resetting the cache, etc., but cannot find a reason for this. I can use Drupal core classes in myController.php, but nothing from the themes directory (I tried to include custom code from another custom theme).
Any hints? Any best-practice work-arounds?