DDC-1838: [GH-357] Persistent and Called First ClassName #2319

Closed
opened 2026-01-22 13:48:17 +01:00 by admin · 1 comment
Owner

Originally created by @doctrinebot on GitHub (May 25, 2012).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user @beberlei:

This issue is created automatically through a Github pull request on behalf of bpanahij:

Url: https://github.com/doctrine/doctrine2/pull/357

Message:

--Allow the use of the ClassName in Naming functions other than just setting the table name

I am using it to add a table name prefix to all of my columns within the table;
as follows:

<?php
/****
* Author: Brian P Johnson
* Date: 5/24/12
* Time: 8:23 AM
*/
require_once('/usr/src/doctrine2-orm/lib/Doctrine/ORM/Mapping/NamingStrategy.php'); 
use Doctrine\ORM\Mapping\NamingStrategy;

class rateGeniusNamingStrategy implements NamingStrategy
{
    public $className = '';
    public $prefix = '';

    public function setClassName($className) {

        $this->className = $className;

        $className = 'AdverseActionNaming';
        $capString = preg_replace('/[^A-Z]/','',$className);
        if(strlen($capString) < 4)
        {
            $capString = substr($capString,0,1).substr($className,1,4-strlen($capString)).substr($capString,1,3);
        }

        $this->prefix = strtoupper($capString);
    }

public function classToTableName($className)
{
    $wordArray = preg_split('/(?=\p{Lu})/u', $className);
    $table*name*body = '';
    $count = 0;
    $word = "";
    foreach($wordArray as $word)
    {
        $table*name_body .= '*'.strtoupper($word);
        $count<ins></ins>;
    }
    return $this->prefix.$table*name*body;
}

public function propertyToColumnName($propertyName)
{
    $wordArray = preg_split('/(?=\p{Lu})/u', $propertyName);
    $column*name*body = '';
    foreach($wordArray as $word)
    {
        $column*name_body .= '*'.strtoupper($word);
    }
    return $this->prefix.$column*name*body;
}

public function referenceColumnName()
{
    return $this->prefix.'_ID';
}

public function joinColumnName($propertyName)
{
    $table*name_parts = preg_split('/*/',$this->joinTableName());
    return $this->prefix .'*' . $table_name_parts[0] . '*' . $this->referenceColumnName();
}

public function joinTableName($sourceEntity, $targetEntity, $propertyName = null)
{
    return strtoupper($this->classToTableName($sourceEntity) . '_' .
        $this->classToTableName($targetEntity));
}

public function joinKeyColumnName($entityName, $referencedColumnName = null)
{
    return strtoupper($this->classToTableName($entityName) . '_' .
        ($referencedColumnName ?: $this->referenceColumnName()));
}

}

Originally created by @doctrinebot on GitHub (May 25, 2012). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user @beberlei: This issue is created automatically through a Github pull request on behalf of bpanahij: Url: https://github.com/doctrine/doctrine2/pull/357 Message: --Allow the use of the ClassName in Naming functions other than just setting the table name I am using it to add a table name prefix to all of my columns within the table; as follows: ``` <?php /**** * Author: Brian P Johnson * Date: 5/24/12 * Time: 8:23 AM */ require_once('/usr/src/doctrine2-orm/lib/Doctrine/ORM/Mapping/NamingStrategy.php'); use Doctrine\ORM\Mapping\NamingStrategy; class rateGeniusNamingStrategy implements NamingStrategy { public $className = ''; public $prefix = ''; public function setClassName($className) { $this->className = $className; $className = 'AdverseActionNaming'; $capString = preg_replace('/[^A-Z]/','',$className); if(strlen($capString) < 4) { $capString = substr($capString,0,1).substr($className,1,4-strlen($capString)).substr($capString,1,3); } $this->prefix = strtoupper($capString); } public function classToTableName($className) { $wordArray = preg_split('/(?=\p{Lu})/u', $className); $table*name*body = ''; $count = 0; $word = ""; foreach($wordArray as $word) { $table*name_body .= '*'.strtoupper($word); $count<ins></ins>; } return $this->prefix.$table*name*body; } public function propertyToColumnName($propertyName) { $wordArray = preg_split('/(?=\p{Lu})/u', $propertyName); $column*name*body = ''; foreach($wordArray as $word) { $column*name_body .= '*'.strtoupper($word); } return $this->prefix.$column*name*body; } public function referenceColumnName() { return $this->prefix.'_ID'; } public function joinColumnName($propertyName) { $table*name_parts = preg_split('/*/',$this->joinTableName()); return $this->prefix .'*' . $table_name_parts[0] . '*' . $this->referenceColumnName(); } public function joinTableName($sourceEntity, $targetEntity, $propertyName = null) { return strtoupper($this->classToTableName($sourceEntity) . '_' . $this->classToTableName($targetEntity)); } public function joinKeyColumnName($entityName, $referencedColumnName = null) { return strtoupper($this->classToTableName($entityName) . '_' . ($referencedColumnName ?: $this->referenceColumnName())); } ``` }
admin added the Bug label 2026-01-22 13:48:17 +01:00
admin closed this issue 2026-01-22 13:48:18 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jul 5, 2012):

Issue was closed with resolution "Invalid"

@doctrinebot commented on GitHub (Jul 5, 2012): Issue was closed with resolution "Invalid"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#2319