Overwrite class methods outside of modules
Hi, I found the documentation which explains how you can overwrite module class methods to protect against updates wiping out your changes but I wondered if this is possible with system classes?
Specifically I am working on an extension that works with the backend login screen. The BE login is loaded from the class 'index' which is located in the contao folder in the root directory of Contao.
Is there a way I can overwrite the 'run' method without amending the actual file?
Thanks
Re: Overwrite class methods outside of modules
Hi,
There is no way you can override the contao/index:Index run method without creating a new file. You could hack around this using Apache index directs on the directory but this is bad practice from the perspective of writing a reusable Contao module. Other PHP hacks such as namespaces wouldn't be possible afaik.
If you could go into more details about exactly what you're trying to achieve by editing the run method, I see that the run method just sets template data and outputs it. So you could use the Contao hook outputBackendTemplate (http://www.contao.org/hooks.html#outputBackendTemplate)
Re: Overwrite class methods outside of modules
Thanks that should work, i'll give it a try.