Skip to content

Instantly share code, notes, and snippets.

@garex
Created September 27, 2016 09:49
Show Gist options
  • Save garex/40158209878d59b96320f5d2a58a4611 to your computer and use it in GitHub Desktop.
Save garex/40158209878d59b96320f5d2a58a4611 to your computer and use it in GitHub Desktop.
Transform "Vendor\FooBundle\Command\BarCommand" transforms to "vendor_foo.command.bar" id
/**
* Transforms "Vendor\FooBundle\Command\BarCommand" transforms to "vendor_foo.command.bar" id
*
* @param string $className
* @return string
*/
private function convertClassToId($className)
{
$id = preg_replace('/^(\w+)\\\(\w+)Bundle.*\\\(\w+)(Command)$/', '$1_$2.$4.$3', $className);
return strtolower($id);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment