diff --git a/application/Espo/Core/Utils/Database/Orm/RelationManager.php b/application/Espo/Core/Utils/Database/Orm/RelationManager.php index 4d9903bcb0..7c952e194e 100644 --- a/application/Espo/Core/Utils/Database/Orm/RelationManager.php +++ b/application/Espo/Core/Utils/Database/Orm/RelationManager.php @@ -118,7 +118,7 @@ class RelationManager $method = $currentType; if ($foreignLink !== false) { - $method .= '-'.$foreignLink['params']['type']; + $method .= '_' . $foreignLink['params']['type']; } $method = Util::toCamelCase($method); diff --git a/application/Espo/Core/Utils/Database/Orm/Relations/ManyMany.php b/application/Espo/Core/Utils/Database/Orm/Relations/ManyMany.php index 54e4e109a3..58cd78bb64 100644 --- a/application/Espo/Core/Utils/Database/Orm/Relations/ManyMany.php +++ b/application/Espo/Core/Utils/Database/Orm/Relations/ManyMany.php @@ -63,7 +63,7 @@ class ManyMany extends Base { $tables = $this->getSortEntities($tableName1, $tableName2); - return Util::toCamelCase( implode('-', $tables) ); + return Util::toCamelCase( implode('_', $tables) ); } protected function getSortEntities($entity1, $entity2) diff --git a/application/Espo/Core/Utils/Util.php b/application/Espo/Core/Utils/Util.php index bb205362ae..e2de1158c5 100644 --- a/application/Espo/Core/Utils/Util.php +++ b/application/Espo/Core/Utils/Util.php @@ -60,13 +60,15 @@ class Util /** - * Convert name to Camel Case format, ex. camel-case to camelCase + * Convert name to Camel Case format, ex. camel_case to camelCase + * * @param string $name - * @param boolean $capitaliseFirstChar * @param string $symbol + * @param boolean $capitaliseFirstChar + * * @return string */ - public static function toCamelCase($name, $capitaliseFirstChar = false, $symbol = '-') + public static function toCamelCase($name, $symbol = '_', $capitaliseFirstChar = false) { if($capitaliseFirstChar) { $name[0] = strtoupper($name[0]); @@ -87,7 +89,7 @@ class Util * * @return string */ - public static function fromCamelCase($name, $symbol = '-') + public static function fromCamelCase($name, $symbol = '_') { $name[0] = strtolower($name[0]); return preg_replace_callback('/([A-Z])/', function ($matches) use ($symbol) { @@ -236,12 +238,12 @@ class Util * * @return string */ - public static function getNaming($name, $prePostFix, $type = 'prefix', $symbol = '-') + public static function getNaming($name, $prePostFix, $type = 'prefix', $symbol = '_') { if ($type == 'prefix') { - return static::toCamelCase($prePostFix.$symbol.$name, false, $symbol); + return static::toCamelCase($prePostFix.$symbol.$name, $symbol); } else if ($type == 'postfix') { - return static::toCamelCase($name.$symbol.$prePostFix, false, $symbol); + return static::toCamelCase($name.$symbol.$prePostFix, $symbol); } return null; diff --git a/tests/Espo/Core/Utils/UtilTest.php b/tests/Espo/Core/Utils/UtilTest.php index 7697d4512b..889ac39635 100644 --- a/tests/Espo/Core/Utils/UtilTest.php +++ b/tests/Espo/Core/Utils/UtilTest.php @@ -14,16 +14,16 @@ class UtilTest extends \PHPUnit_Framework_TestCase public function testToCamelCase() { $this->assertEquals('detail', Util::toCamelCase('detail')); - $this->assertEquals('detailView', Util::toCamelCase('detail-view')); - $this->assertEquals('myDetailView', Util::toCamelCase('my-detail-view')); + $this->assertEquals('detailView', Util::toCamelCase('detail-view', '-')); + $this->assertEquals('myDetailView', Util::toCamelCase('my_detail_view')); } public function testFromCamelCase() { $this->assertEquals('detail', Util::fromCamelCase('detail')); - $this->assertEquals('detail-view', Util::fromCamelCase('detailView')); - $this->assertEquals('my-detail-view', Util::fromCamelCase('myDetailView')); - $this->assertEquals('my-f-f', Util::fromCamelCase('myFF')); + $this->assertEquals('detail-view', Util::fromCamelCase('detailView', '-')); + $this->assertEquals('my_detail_view', Util::fromCamelCase('myDetailView')); + $this->assertEquals('my_f_f', Util::fromCamelCase('myFF')); } public function testToUnderScoree()