Created
July 4, 2012 12:05
-
-
Save fixe/3046996 to your computer and use it in GitHub Desktop.
A naming strategy to get lowercase tables and underscorified fields
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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