Skip to content

Instantly share code, notes, and snippets.

@fixe
Created July 4, 2012 12:05
Show Gist options
  • Save fixe/3046996 to your computer and use it in GitHub Desktop.
Save fixe/3046996 to your computer and use it in GitHub Desktop.
A naming strategy to get lowercase tables and underscorified fields
<?php
namespace Seegno\Bundle\ToolkitBundle\Doctrine\ORM\Mapping;
use Doctrine\ORM\Mapping\DefaultNamingStrategy as BaseDefaultNamingStrategy;
use Doctrine\Common\Util\Inflector;
class DefaultNamingStrategy extends BaseDefaultNamingStrategy
{
/**
* {@inheritdoc}
*/
public function classToTableName($className)
{
return Inflector::tableize(parent::classToTableName($className));
}
/**
* {@inheritdoc}
*/
public function propertyToColumnName($propertyName)
{
return Inflector::tableize(parent::propertyToColumnName($propertyName));
}
/**
* {@inheritdoc}
*/
public function joinColumnName($propertyName)
{
return Inflector::tableize($propertyName) . '_' . $this->referenceColumnName();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment