Extend Typo3 Function using Xclass in Extbase Extension

Here is the few steps on how to extend a function Using XCLASS

Step1:
Add Below code in ext_localconf.php

$GLOBALS[‘TYPO3_CONF_VARS’][‘SYS’][‘Objects’][‘tx_realurl’] = array(
‘className’ => ‘Vendername\\Extensionname\\Xclass\\Realurl’
);

Step2:
Finally Create File with name Realurl.php in Xclass Folder
<?php
namespace Vendername\Extensionname\Xclass;

class Realurl extends \tx_realurl {
public function encodeSpURL(&$params) {
// Do Your Stuff
devlog(‘ I am here.’);
parent::encodeSpURL($params);
}
}
?>

Step3:
Clear the cache and check whether xclass is included or not.

Thats it.