How to modify the \Magento\Customer\Block\Account\AuthorizationLink::getLabel() method («Sign In» / «Sign Out» text)?

I have created a block in my custom module to override \Magento\Customer\Block\Account\AuthorizationLink my class is working fine but it not overriding the

public function getLabel()
        //return $this->isLoggedIn() ? __('logout') : __('login');

can any one helpme ?

The best way to change the «Sign In» / «Sign Out» text is to use a custom language dictionary and set the required translaction for the «Sign In» and «Sign Out» phrases.

Another way is to use a plugin.
Your way (rewrite all the class) is the worst, because it will conflict with other extensions which need to make some changes in the \Magento\Customer\Block\Account\AuthorizationLink class (for example, another extension can try to modify the getHref() method, and will break your extension or will be broken by your extension).

See also:

1 Like