Overriding the core through package?
Permalink
anyone know of a clean way of overriding/extending some of the core components through a package so you don't have to place the custom code in the base dir?
the only way i can think of is perhaps to maybe place your files in your package structure corresponding to the files you want to override/extend in the core, and in the install function of the package, copy the file to the base dir structure, and in the uninstall function do the opposite by removing.
however this obviously creates problems if, say a custom file already exist in the base dir structure where you wanna copy your package file.
anyone following?
the only way i can think of is perhaps to maybe place your files in your package structure corresponding to the files you want to override/extend in the core, and in the install function of the package, copy the file to the base dir structure, and in the uninstall function do the opposite by removing.
however this obviously creates problems if, say a custom file already exist in the base dir structure where you wanna copy your package file.
anyone following?
thanks for the reply.
the problem though, or well, what i was trying to say, is that i want to be able to override the actual core's behavior, not just use some logic inside my package as a compliment.
for instance, if you want to change the behavior of how a file is being saved when using the file manager, you could go and put a duplicate with your desired changes in that very same path outside of the concrete core folder and get the desired effects.
however, if a package is dependant on this, there doesn't seem to be a way of keeping those duplicate files within the package folder, thus eliminating the plug & play of the package, since you would manually have to copy files over.
confusing?! not on my a game today with my explanation.
the problem though, or well, what i was trying to say, is that i want to be able to override the actual core's behavior, not just use some logic inside my package as a compliment.
for instance, if you want to change the behavior of how a file is being saved when using the file manager, you could go and put a duplicate with your desired changes in that very same path outside of the concrete core folder and get the desired effects.
however, if a package is dependant on this, there doesn't seem to be a way of keeping those duplicate files within the package folder, thus eliminating the plug & play of the package, since you would manually have to copy files over.
confusing?! not on my a game today with my explanation.
Loader::model('blog_directory','blog');
blog_directory being the php file under the blog app package/model directory, and blog specifies the directory under packages the loader should look for.
That being said you could theoretically copy a file to the directory assuming it is writeable by the server, but usually it will suffice to use the second parameter under loader which is designated to reference a package.
in the case of an element, you'll want to use Loader::packageElement. elements use an args array which is the reason for the three parameter loader function there.
-Scott