1
0
mirror of synced 2025-02-02 21:41:45 +03:00

Fix typos and wording in NamingStrategy documentation

This commit is contained in:
Sven Cannivy 2017-02-10 18:48:57 +01:00
parent 23ae83e351
commit 260c8d0113

View File

@ -3,21 +3,18 @@ Implementing a NamingStrategy
.. versionadded:: 2.3
Using a naming strategy you can provide rules for automatically generating
database identifiers, columns and tables names
when the table/column name is not given.
This feature helps reduce the verbosity of the mapping document,
eliminating repetitive noise (eg: ``TABLE_``).
Using a naming strategy you can provide rules for generating database identifiers,
column or table names when the column or table name is not given. This feature helps
reduce the verbosity of the mapping document, eliminating repetitive noise (eg: ``TABLE_``).
Configuring a naming strategy
-----------------------------
The default strategy used by Doctrine is quite minimal.
By default the ``Doctrine\ORM\Mapping\DefaultNamingStrategy``
uses the simple class name and the attributes names to generate tables and columns
uses the simple class name and the attribute names to generate tables and columns.
You can specify a different strategy by calling ``Doctrine\ORM\Configuration#setNamingStrategy()`` :
You can specify a different strategy by calling ``Doctrine\ORM\Configuration#setNamingStrategy()``:
.. code-block:: php
@ -28,8 +25,7 @@ You can specify a different strategy by calling ``Doctrine\ORM\Configuration#set
Underscore naming strategy
---------------------------
``\Doctrine\ORM\Mapping\UnderscoreNamingStrategy`` is a built-in strategy
that might be a useful if you want to use a underlying convention.
``\Doctrine\ORM\Mapping\UnderscoreNamingStrategy`` is a built-in strategy.
.. code-block:: php
@ -37,14 +33,13 @@ that might be a useful if you want to use a underlying convention.
$namingStrategy = new \Doctrine\ORM\Mapping\UnderscoreNamingStrategy(CASE_UPPER);
$configuration()->setNamingStrategy($namingStrategy);
Then SomeEntityName will generate the table SOME_ENTITY_NAME when CASE_UPPER
or some_entity_name using CASE_LOWER is given.
For SomeEntityName the strategy will generate the table SOME_ENTITY_NAME with the
``CASE_UPPER`` option, or some_entity_name with the ``CASE_LOWER`` option.
Naming strategy interface
-------------------------
The interface ``Doctrine\ORM\Mapping\NamingStrategy`` allows you to specify
a "naming standard" for database tables and columns.
a naming strategy for database tables and columns.
.. code-block:: php
@ -101,10 +96,11 @@ a "naming standard" for database tables and columns.
Implementing a naming strategy
-------------------------------
If you have database naming standards like all tables names should be prefixed
by the application prefix, all column names should be upper case,
you can easily achieve such standards by implementing a naming strategy.
You need to implements NamingStrategy first. Following is an example
If you have database naming standards, like all table names should be prefixed
by the application prefix, all column names should be upper case, you can easily
achieve such standards by implementing a naming strategy.
You need to create a class which implements ``Doctrine\ORM\Mapping\NamingStrategy``.
.. code-block:: php
@ -139,12 +135,3 @@ You need to implements NamingStrategy first. Following is an example
($referencedColumnName ?: $this->referenceColumnName()));
}
}
Configuring the namingstrategy is easy if.
Just set your naming strategy calling ``Doctrine\ORM\Configuration#setNamingStrategy()`` :.
.. code-block:: php
<?php
$namingStrategy = new MyAppNamingStrategy();
$configuration()->setNamingStrategy($namingStrategy);