1

There is a getAssetTemplate function in magento/vendor/magento/framework/View/Page/Config/Renderer.php.

I want to override it to make render things in a bit different way.

I don't want to update these files from vendor directory. What would be the proper way to make changes to this function?

The general question is what is the way to override classes under vendor/magento/framework?

1

You can do it by using Preference
Just simply add this line to your di.xml file of your custom module.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
   <preference for="Magento\Framework\View\Page\Config\Renderer.php" type="vendor\module\View\Page\Config\Renderer.php" />

</config>  

vendor\module\View\Page\Config\Renderer.php is your class that extends Magento\Framework\View\Page\Config\Renderer.php, through it you can make whatever changes you want.

Note: change vendor\module according to your real custom module

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.