Dynamic Attribute Category Model File
Permalink
Negating the option to modify core code...
If a package contains multiple new AttributeKeyCategories, is there a way to use one file to dynamically model each class, rather than creating a new file for each one?
If a package contains multiple new AttributeKeyCategories, is there a way to use one file to dynamically model each class, rather than creating a new file for each one?
I don't understand what you mean.
Not really, no. You could potentially create a base model for each one, and have each class extend it...but you'll need at least one file for each attribute category in the categories folder, named properly, etc..
@Scott: I'm essentially referring to AttributeKeyCategory::getAttributeKeyBy...() functions in the ~/concrete/models/attribute/categories.php file.
I was hoping for a magic method that, if the file didn't exist, it would ask the package what to do.
Thanks for the response Andrew. So just to clarify...
If, in a package's install method, I ran:there must be a file in ~/packages/package_handle/models/attribute/categories/($handle).php or c5 would break if I ever tried to get an AttributeKey by using the AttributeKeyCategoy class.
I was hoping for a magic method that, if the file didn't exist, it would ask the package what to do.
Thanks for the response Andrew. So just to clarify...
If, in a package's install method, I ran:
AttributeKeyCategory::add($handle, $allowSets, $pkg);
Yeah... there's just no way of creating new AttributeKeyCategories on the fly without creating a wrapper model file.
Which is doable, but not ideal.
Would be nice if we could see a conditional that:
if the file doesn't exist, look in the package controller, or ask the package controller for a specific file.
Which is doable, but not ideal.
Would be nice if we could see a conditional that:
if the file doesn't exist, look in the package controller, or ask the package controller for a specific file.