2

I am writing a plugin on class Magento\Payment\Model\MethodInterface:

<type name=“Magento\Payment\Model\MethodInterface”>
   <plugin name=“mageworx_ordereditor_change_title_print_order”
           type=“MageWorx\OrderEditor\Plugin\Block\Sales\Adminhtml\Order\View\Payment”/>
</type>

In Magento before 2.2.0 class Magento\Vault\Model\Method\Vault has "final class Vault" but after 2.2.0 the class is "class Vault"

When I launch the following command in Magento 2.1.9 bin/magento setup:di:compile I get error:

Class Magento\Vault\Model\Method\Vault\Interceptor may not inherit from final class (Magento\Vault\Model\Method\Vault) in /home/zalescky/web/m219e/var/generation/Magento/Vault/Model/Method/Vault/Interceptor.php on line 7
PHP Stack trace:
PHP   1. {main}() /home/zalescky/web/m219e/bin/magento:0
PHP   2. Symfony\Component\Console\Application->run() /home/zalescky/web/m219e/bin/magento:23
PHP   3. Magento\Framework\Console\Cli->doRun() /home/zalescky/web/m219e/vendor/symfony/console/Symfony/Component/Console/Application.php:126
PHP   4. Symfony\Component\Console\Application->doRun() /home/zalescky/web/m219e/vendor/magento/framework/Console/Cli.php:96
PHP   5. Symfony\Component\Console\Application->doRunCommand() /home/zalescky/web/m219e/vendor/symfony/console/Symfony/Component/Console/Application.php:195
PHP   6. Symfony\Component\Console\Command\Command->run() /home/zalescky/web/m219e/vendor/symfony/console/Symfony/Component/Console/Application.php:874
PHP   7. Magento\Setup\Console\Command\DiCompileCommand->execute() /home/zalescky/web/m219e/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:257
PHP   8. Magento\Setup\Module\Di\App\Task\Manager->process() /home/zalescky/web/m219e/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php:188
PHP   9. Magento\Setup\Module\Di\App\Task\Operation\Interception->doOperation() /home/zalescky/web/m219e/setup/src/Magento/Setup/Module/Di/App/Task/Manager.php:56
PHP  10. Magento\Setup\Module\Di\Code\Generator->generateList() /home/zalescky/web/m219e/setup/src/Magento/Setup/Module/Di/App/Task/Operation/Interception.php:100
PHP  11. Magento\Framework\Code\Generator->generateClass() /home/zalescky/web/m219e/setup/src/Magento/Setup/Module/Di/Code/Generator.php:70
PHP  12. Magento\Framework\Code\Generator\Io->includeFile() /home/zalescky/web/m219e/vendor/magento/framework/Code/Generator.php:118
PHP  13. include() /home/zalescky/web/m219e/vendor/magento/framework/Code/Generator/Io.php:158

In my extension I want to write a plugin for each payment method, but the final payment method class doesn’t allow me to do this. How will it be better to cope with this?

0

Yes, Final method is concept in oops magento , It doesn't allows. You need to use Event observer or over-ridding way of implementation for payment method functionalities , you wish to customize. URL : https://inchoo.net/magento-2/overriding-classes-magento-2/ Let me know your feedback.

  • kindly follow above suggested steps and things will work. – Ramesh Chauhan Sep 4 '18 at 11:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.