Hi
I have a 3rd party plugin which I'm in the process of extending with another plugin, but I would like to modify one of the classes in the 3rd party plugin. I don't want to edit the code within the 3rd party plugin.
I know in the start.php there is the elgg_register_class() function which you register classes is there a respective function which you can unregister a class?
Thanks
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Juho Jaakkola@juho.jaakkola

Juho Jaakkola - 0 likes
- DhrupDeScoop@Dhrup2000

DhrupDeScoop - 0 likes
- Juho Jaakkola@juho.jaakkola

Juho Jaakkola - 0 likes
- DhrupDeScoop@Dhrup2000

DhrupDeScoop - 0 likes
- Cash@costelloc

Cash - 0 likes
- Dominic Milburn@steeloctopus

Dominic Milburn - 0 likes
You must log in to post replies.Lets say that there's an entity like this:
type: object
subtype: blog
class: ElggBlog
Copy the ElggBlog.php class to your plugin for example as ElggMyblog.php, make modifications to it and then register the blog subtype to use your class with this function:
If the ElggMyblog class is found from the classes/ directory of your plugin, the blog entities now use your class instead of the original ElggBlog class.
This function needs to be run only once so but it to a file activate.php in your plugin. This file is run when the plugin is activated. Also add a file deactivate.php which updates the class back to the original, so that nothing gets broken when you deactivate your own plugin.
You can see an example of the activate.php in the blog plugin.
is it not simpler, easier for you to extend the original class and code your extensions, overides like in proper OOP ? you just are bt allowed to subtract variables, functions from extended class.
Got to say that Dhrup's approach is better. For some reason I didn't think that far.
huhh ? ;-)
I guess that maybe we just 'read' into Dominic's situation description differently..
and I happened to be lazy and not want to read / quote elgg code in order to answer ;-P
and
typo in my post =
'..just are not allowed to subtract.. '
On how to change what class file is used, calling elgg_register_class() with a new location should overwrite the old location.
Hi Guys
Thanks for your responces, I did think about using OOP inhertiance but that requires a new class name and I did not want to go and change all the references that instantate old class with the new class but @cash solution has worked really well.
Once elgg_register_class() called in the start file the new class definition was loaded.
thank you