2

I want to override public static function getCorrectFileName method of Magento\Framework\File\Uploader, I have check with Preference and Plugin but it is not working for me.

Anyone have idea about this ?

4
  • you cannot override static functions. Commented Jan 24, 2020 at 6:41
  • We can not override with Preference ? Commented Jan 24, 2020 at 6:42
  • We can't override using preference. Try with other method Commented Jan 24, 2020 at 6:43
  • I hope this answer will help you. magento.stackexchange.com/questions/293100/… Commented Jan 24, 2020 at 7:12

1 Answer 1

2

Overwriting a static method is impossible, because the interpreter call them using a class name directly, so no one preference could get around this logic. It is a PHP restriction, not Magento. You can create a similar module\class and use it instead of the base Magento module\class.

3
  • Yes right @Siarhey Uchukhlebau, I have do another way and it working fine. Commented Jan 27, 2020 at 11:45
  • @NiranjanGondaliya Can you let me know how did you achieve it? I need to increase filename length condition to 128 instead of 90 in that static function. Commented Jan 31, 2021 at 20:16
  • @NiranjanGondaliya How did you go about extending or overwriting this method? Commented Jul 15, 2021 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.