refreshToken() doesn't return the token. It creates a new token and replaces the old token that is already in the session. This is why I call it refresh token. 

I have to admit, I'm surprised that these simple functions that actually only serve the purpose of moving the responsibility for session checks into a reusable function (making building controllers easier) would be so heavily debated, while the fact that the inversion of the controller.task hasn't even gotten a mention. 

Crazy world we live in.


Sincerely,
Mathew Lenning

Babel-university.com

P.S. This message was sent via iPhone, so please forgive any errors

> On Apr 26, 2014, at 4:54 PM, Thomas Hunziker <notifications@github.com> wrote:
> 
> In libraries/cms/controller/base.php:
> 
> > +	 * @return void
> > +	 */
> > +	protected function refreshToken()
> > +	{
> > +		$session = JFactory::getSession();
> > +		$session->getToken(true);
> > +	}
> > +	
> > +	/**
> > +	 * Method to translate a string using JText::_() method
> > +	 * @param string $string
> > +	 * @return string translation result
> > +	 */
> > +	protected function translate($string)
> > +	{
> > +		return JText::_($string);
> Tell me which of these express the intention which is "To refresh the session token"
> 
> Actually, I don't want to refresh an existing token. I just want to issue a new token. So $this->refreshToken() would be misleading and JFactory::getSession()->getToken(true); would be what I want.
> 
> JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); does more than "make sure the current session is valid". It also ends the script if it's not. So the method name would be wrong anyway. If you want to make it correct you would have to use. The function to validate is JSession::checkToken() which describes exactly what it does. The jexit is already the fail condition of the failed validating.
> 
> It may come down to personal preferences of course. However I'm a big fan of keeping PRs on its topic and adding new methods to wrap static calls doesn't seem to be needed for adding single task contollers.
> 
> \
> Reply to this email directly or view it on GitHub.