Overriding module class in prestashop 1.7.6 - prestashop-1.7

I'm trying to override a class from a module I installed. The class is located in the modules folder in MyModule/lib/MyClass.php
So what i did is create a copy of that class in override/modules/MyModule/lib/MyClass.php and it's declared like this:
class MyClassOverride extends MyClass {
// custom code
}
I also deleted the class_index.php file.
And my changes are not applied so i really don't know what I am missing here. Is it even possible to do that ? I heard that in previous versions of prestashop you couldn't override a module class...
Anyone has an idea ?

I have the same problem.
It seems that it's possible to override a php class for a module if the class is in MyModule/MyClass.php, but it doesn't work if the class is in MyModule/lib/MyClass.php...

Related

Grails 3.2 with Intellij cannot extend plugin class

I have a base plugin class that cannot be resolved. It is like this:
package my.project
class NotificationController extends my.notification.plugin.NotificationController {...}
Upon building, the error I receive is
Error:(11, 1) Groovyc: unable to resolve class my.notification.plugin.NotificationController
Same thing for the Notification service.
Is this an Intellij thing or a Grails/Gradle thing? And is there a cure?
The answer is - you can't extend the controller because of the special processing grails applies to a controller. If one must do this, the base plugin should partition the controller "guts" into a regular class. Then, both the plugin and the main app can extend the regular class. Of course this is not quite the same as extending the plugin controller, but it seems to be as close as one can get. And this assumes one has control of the plugin class code...

Controller from package not found

I am trying to make a package and I am new for it, everything is going fine, but when I tried to use controller from package like
but I get
Please Help.
Because your admincontroller extends controller and you used RoshanDev\MiePackage\Controller that same as the class name your admincontroller exetends.
Solution is change it with as:
use RoshanDev\MiePackage\Controller as ctr;

Extend the Laravel\Lumen\Exceptions\Handler.php inside package

I've got several Lumen services that have the same code inside the render() function within the App\Exceptions\Handler.php class. I want to move this code to a separate package that all of the services can include. I was able to get this working by making the package Handler.php file extend the Laravel\Lumen\Exceptions\Handler.php class, basically inserting my class between the default framework file and the Handler that users edit.
Change:
class Handler extends Laravel\Lumen\Exceptions\Handler {...}
To:
My class
use Laravel\Lumen\Exceptions\Handler;
class MyHandler extends Handler {...}
Framework class
use ServiceHelpers\Exceptions\MyHandler;
class Handler extends MyHandler {...}
However I ran into the problem where Laravel\Lumen\Exceptions\Handler doesn't exist when unit testing my file within the package. I've requires several illuminate/... packages in my composer file but it looks like the file I'm trying to extend is in the Laravel or Lumen framework and I'd have to require the laravel/lumen package which I don't think is appropriate.
I'm currently have the following required:
"illuminate/support": "^5.5",
"illuminate/http": "^5.5",
"illuminate/validation": "^5.5",
The error I'm getting is:
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Laravel\Lumen\Exceptions\Handler' not found
Well, technically, your package depends on laravel/lumen-framework being installed, since it is extending a class from that package. Because of this, having laravel/lumen-framework as a dependency for your package is appropriate; your package depends on it being installed.

Visual Studio 2013 is not able to recognise the class file added as Add > Existing Item > File "Add as link"

I am trying to add an external C# file. It's added to the project but the IDE is not able to recognize the class, even the class name is not reflected into the intellisence option. I am working on a c# desktop application on VS2013.
What am I missing here?
i suspect that the newly added class is inside the different namespace than from where you are trying to access it.
if that is the case just try to access the newly added class using its namespace asbelow:
namespace newlyaddednamespace
{
class newclass
{
//this is the class added newly
}
}
namespace mynamespace
{
class myclass
{
//access the newly added class from its namespace
newlyaddednamespace.newclass newclassObj=new newlyaddednamespace.newclass();
}
}
Set the Build Action for that file to Compile.

Overload Library Class Methods with Magento 1.6v or higher

I have Magento version 1.6 and I want to like overload a method in a class which is located in {root}/lib folder. I have seen that there are no problems If I want to overload magento methods in the {root}/app/code/mage folder.
But my problem is, how can I overload specific methods in a class from magento library lib folder?
AFAIK, the only way to override the lib class file is to use the same folder structure as that of lib in app/code/local pool.
For example if you want to override
lib/Varien/Image.php
then you should copy the file to:
app/code/local/Varien/Image.php
But in case of lib class's method overriding. i don't think if that's possible unless you modify the autoload classes.
Thanks

Resources