Using Autoloader Registry for Core Class Extensions

Permalink
We've setup Razor\Core as our namespace mapping to 'src' using the $pkgAutoloaderRegistries in package controller. It's worked beautifully and we load everything in /src using Razor\Core. Now we've needed to add an AttributeKey for a custom object. What we find is that when you add an AttributeKeyCategory, there is a method call that is made that expects your AttributeKey to sit at /src/Attribute/Key/YourKey. And if it isn't there, it doesn't seem to respect mapping. In other words we cannot use Razor\Core\Attribute\Key\NewKey instead we have to resort to the Concrete\Package\Razor\Attribute\Key\NewKey.

Ideally we want to actually avoid having a src/Attribute/ altogether and instead use src/Product/Attribute/Key and src/Product/Attribute/Value. And use our autoloader so we can call them with Razor\Core\Product\Attribute\Key and Razor\Core\Product\Attribute\Value respectively.

There is a helper function used at one point that gives us some hint on how to do this it's core_class( $class, $prefix ). In a package core_class is called with $prefix = 'package_handle' and then the package handle is camel-cased and worked into the call to the class. Problem is the class is still expected to sit at a specific location inside the package unless you can pass $prefix yourself. Which you cannot, because this core_class() is called for you, and you cannot pass a custom $prefix into it.

razorcommerce
 
JohntheFish replied on at Permalink Reply
JohntheFish
I don't have an answer for you, just a further complication. Another factor to bear in mind when setting up namespaces is whether it can be overridden. In eCommerce support threads, an override with some custom adjustments to the code is often part of the solution.