Skip to content

Instantly share code, notes, and snippets.

@Herzult
Created November 4, 2010 15:07
Show Gist options
  • Save Herzult/662592 to your computer and use it in GitHub Desktop.
Save Herzult/662592 to your computer and use it in GitHub Desktop.
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. - Martin Golding
<?php
class UserGroup extends BaseUserGroup
{
/**
* Overwrites the parent getName to return a translated string
*
* @return translated name as string
*/
public function getName()
{
return (sfContext::hasInstance()) ? sfContext::getInstance()->getI18N()->__(parent::_get('name')) : '';
}
}
@ornicar
Copy link

ornicar commented Nov 4, 2010

Note that without a symfony context, the code fails silently, returning an empty string instead of the group name. Awesome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment