hi all,
In the file util/sfInflector.class.php, there is a static method
called underscore:
-----------------------
public static function underscore($camel_cased_word)
{
$tmp = $camel_cased_word;
$tmp = str_replace('::', '/', $tmp);
$tmp = sfToolkit::pregtr($tmp, array('/([A-Z]+)([A-Z][a-z])/' => '\
\1_\\2',
'/([a-z\d])([A-Z])/' => '\
\1_\\2'));
return strtolower($tmp);
}
-----------------------
some tests:
sfInflector::underscore('HelloWorld') => hello_world
sfInflector::underscore('HelloWorldAgain') =>
hello_world_again
sfInflector::underscore('HelloWorld2') => hello_world2
sfInflector::underscore('HelloWorld234Again') =>
hello_world234_again
If there is field called " gb_iso_2312 " in the database table,
the result is gb_iso2312.
This generates problems when using the admin generator, in particular,
when sorting and filtering the field.
I created an account on TRAC but it seems I' m unable to open tickets.
Is it possible to give me such permission? My account is 'zhou'.
Below is a quick patch that works according to my tests:
-----------------------
public static function underscore($camel_cased_word)
{
$tmp = $camel_cased_word;
$tmp = str_replace('::', '/', $tmp);
$tmp = sfToolkit::pregtr($tmp, array('/([A-Z]+)([A-Z][a-z])/' => '\
\1_\\2',
'/([a-z\d])([A-Z])/' => '\\1_\\2',
'/([\d])([A-Z])/' => '\\1_\\2',
'/([A-Za-z])([\d])/' => '\\1_\\2'));
return strtolower($tmp);
}
-----------------------
Feel free to suggest changes.
Zhou
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---