Skip to content

Conversation

@Almamu
Copy link

@Almamu Almamu commented Dec 13, 2016

Fixes an use case like this one:

<database name="default" defaultIdMethod="native" defaultPhpNamingMethod="underscore" namespace="Database">
  <table name="arclabs_accounts" idMethod="native" phpName="Account" namespace="ArcLaboratories">
    [...]
  </table>
  <table name="mlabs_accounts" idMethod="native" phpName="Account" namespace="MinecraftLaboratories">
    [...]
  </table>
</database>

Fixes an use case like this one:
<database name="default" defaultIdMethod="native" defaultPhpNamingMethod="underscore" namespace="Database">
  <table name="arclabs_accounts" idMethod="native" phpName="Account" namespace="ArcLaboratories">
    [...]
  </table>
  <table name="mlabs_accounts" idMethod="native" phpName="Account" namespace="MinecraftLaboratories">
    [...]
  </table>
</database>
$autoAliasName = 'Child' . $class;
// $autoAliasName = 'Child' . $class;
// FIXME: USE A DIFFERENT SYSTEM TO GENERATE AN UNIQUE NAME FOR THIS CLASS?
$autoAliasName = $class . md5($namespace);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, well, no md5 in names please :P

Copy link
Author

@Almamu Almamu Dec 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That just change the aliases generated for class names (for the use in autogenerated classes, doesnt change any class name) I do agree that MD5 is not the best way, but there are not many ways of doing it. At first I though to generate a name based on the namespace and that could probably be better... for example, get the last namespace and concat it to the class name so a case like the one on the PR generates valid use statements that do not collide. That would generate aliases like MinecraftLaboratoriesAccount and ArcLaboratoriesAccount in case of a collision in the class name, but that could lead to more complex databases to have collisions too (for multiple namespaces or long namespaces, hence md5 does better job in those weird cases, but they are still weird cases anyway...). Would that be a better approach then?

@PhilinTv
Copy link
Contributor

$nsSuffix = str_replace('\\', '', implode('', array_slice(explode('\\', $namespace), -2)));
$autoAliasName = $nsSuffix . $class;
  • test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants