I try to override this file :
vendor/magento/framework/View/Element/Html/Link/Current.php
I create a module.xml, registration.php and di.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Framework\View\Element\Html\Link\Current" type="MyNamespace\MagentoFramework\Model\Framework\View\Element\Html\Link\Current" />
</config>
My override class :
namespace MyNamespace\MagentoFramework\Model\Framework\View\Element\Html\Link;
class Current extends \Magento\Framework\View\Element\Html\Link\Current
{
/**
* Get href URL
*
* @return string
*/
public function getHref()
{
return $this->getUrl($this->getPath());
}
}
The module is enable but this file doesn't override the original.
Do you have any suggestions ?
Thanks !
Best Answer
You can refer the link How to Override Framework Class in Magento 2
They are following the same folder structure in custom namespace or module section.
You can try the same logic without introducing additional folders [model/framework]
OR
You can implement plugin to overwrite the function.
di.xml
Current.php ( Plugin File )
namespace Devi\Customview\Plugin;
Please check and let me know whether its solving your needs.