Skip to content

Instantly share code, notes, and snippets.

@basz
Created May 10, 2015 21:45
Show Gist options
  • Select an option

  • Save basz/f6160c207c81742b949b to your computer and use it in GitHub Desktop.

Select an option

Save basz/f6160c207c81742b949b to your computer and use it in GitHub Desktop.
$em = $e->getApplication()->getServiceManager()->get('doctrine.entity_manager.orm_default');
$filter = new CamelCaseToUnderscore();
$entities = array(
'ZF\OAuth2\Doctrine\Entity\AccessToken',
'ZF\OAuth2\Doctrine\Entity\AuthorizationCode',
'ZF\OAuth2\Doctrine\Entity\Client',
'ZF\OAuth2\Doctrine\Entity\Jti',
'ZF\OAuth2\Doctrine\Entity\Jwt',
'ZF\OAuth2\Doctrine\Entity\PublicKey',
'ZF\OAuth2\Doctrine\Entity\RefreshToken',
'ZF\OAuth2\Doctrine\Entity\Scope',
);
foreach($entities as $entity) {
$cm = $em->getClassMetadata($entity);
$name = explode('\\', $entity);
$name = array_pop($name);
$cm->setTableName(sprintf('oauth2_%s', strtolower($filter->filter($name))));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment