Replacing "Entities" with "Entity"
This commit is contained in:
parent
c8935cc25a
commit
2914c44344
@ -73,7 +73,7 @@ EOT
|
|||||||
|
|
||||||
$type = $input->getArgument('mapping-type') ? $input->getArgument('mapping-type') : 'xml';
|
$type = $input->getArgument('mapping-type') ? $input->getArgument('mapping-type') : 'xml';
|
||||||
if ($type === 'annotation') {
|
if ($type === 'annotation') {
|
||||||
$destPath .= '/Entities';
|
$destPath .= '/Entity';
|
||||||
} else {
|
} else {
|
||||||
$destPath .= '/Resources/config/doctrine/metadata';
|
$destPath .= '/Resources/config/doctrine/metadata';
|
||||||
}
|
}
|
||||||
@ -98,7 +98,7 @@ EOT
|
|||||||
$output->writeln(sprintf('Converting Doctrine 1 schema "<info>%s</info>"', $input->getArgument('d1-schema')));
|
$output->writeln(sprintf('Converting Doctrine 1 schema "<info>%s</info>"', $input->getArgument('d1-schema')));
|
||||||
foreach ($metadata as $class) {
|
foreach ($metadata as $class) {
|
||||||
$className = $class->name;
|
$className = $class->name;
|
||||||
$class->name = $namespace.'\\'.$bundleClass.'\\Entities\\'.$className;
|
$class->name = $namespace.'\\'.$bundleClass.'\\Entity\\'.$className;
|
||||||
if ($type === 'annotation') {
|
if ($type === 'annotation') {
|
||||||
$path = $destPath.'/'.$className.'.php';
|
$path = $destPath.'/'.$className.'.php';
|
||||||
} else {
|
} else {
|
||||||
|
@ -55,7 +55,7 @@ EOT
|
|||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$filterBundle = $input->getOption('bundle') ? str_replace('/', '\\', $input->getOption('bundle')) : false;
|
$filterBundle = $input->getOption('bundle') ? str_replace('/', '\\', $input->getOption('bundle')) : false;
|
||||||
$filterEntity = $filterBundle ? $filterBundle . '\\Entities\\' . str_replace('/', '\\', $input->getOption('entity')) : false;
|
$filterEntity = $filterBundle ? $filterBundle . '\\Entity\\' . str_replace('/', '\\', $input->getOption('entity')) : false;
|
||||||
|
|
||||||
if (!isset($filterBundle) && isset($filterEntity)) {
|
if (!isset($filterBundle) && isset($filterEntity)) {
|
||||||
throw new \InvalidArgumentException(sprintf('Unable to specify an entity without also specifying a bundle.'));
|
throw new \InvalidArgumentException(sprintf('Unable to specify an entity without also specifying a bundle.'));
|
||||||
|
@ -42,7 +42,7 @@ The <info>doctrine:generate:entity</info> task initializes a new Doctrine entity
|
|||||||
|
|
||||||
<info>./symfony doctrine:generate:entity "Bundle\MyCustomBundle" "User\Group"</info>
|
<info>./symfony doctrine:generate:entity "Bundle\MyCustomBundle" "User\Group"</info>
|
||||||
|
|
||||||
The above would initialize a new entity in the following entity namespace <info>Bundle\MyCustomBundle\Entities\User\Group</info>.
|
The above would initialize a new entity in the following entity namespace <info>Bundle\MyCustomBundle\Entity\User\Group</info>.
|
||||||
|
|
||||||
You can also optionally specify the fields you want to generate in the new entity:
|
You can also optionally specify the fields you want to generate in the new entity:
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ EOT
|
|||||||
}
|
}
|
||||||
|
|
||||||
$entity = $input->getArgument('entity');
|
$entity = $input->getArgument('entity');
|
||||||
$entityNamespace = $namespace.'\\'.$bundle.'\\Entities';
|
$entityNamespace = $namespace.'\\'.$bundle.'\\Entity';
|
||||||
$fullEntityClassName = $entityNamespace.'\\'.$entity;
|
$fullEntityClassName = $entityNamespace.'\\'.$entity;
|
||||||
$tmp = str_replace('\\', '/', $fullEntityClassName);
|
$tmp = str_replace('\\', '/', $fullEntityClassName);
|
||||||
$tmp = str_replace('/', '\\', dirname($tmp));
|
$tmp = str_replace('/', '\\', dirname($tmp));
|
||||||
@ -108,7 +108,7 @@ EOT
|
|||||||
$exporter = $cme->getExporter($mappingType);
|
$exporter = $cme->getExporter($mappingType);
|
||||||
|
|
||||||
if ($mappingType === 'annotation') {
|
if ($mappingType === 'annotation') {
|
||||||
$path = $dirs[$namespace].'/'.$bundle.'/Entities/'.str_replace($entityNamespace.'\\', null, $fullEntityClassName).'.php';
|
$path = $dirs[$namespace].'/'.$bundle.'/Entity/'.str_replace($entityNamespace.'\\', null, $fullEntityClassName).'.php';
|
||||||
|
|
||||||
$exporter->setEntityGenerator($this->getEntityGenerator());
|
$exporter->setEntityGenerator($this->getEntityGenerator());
|
||||||
} else {
|
} else {
|
||||||
|
@ -71,7 +71,7 @@ EOT
|
|||||||
|
|
||||||
$type = $input->getArgument('mapping-type') ? $input->getArgument('mapping-type') : 'xml';
|
$type = $input->getArgument('mapping-type') ? $input->getArgument('mapping-type') : 'xml';
|
||||||
if ($type === 'annotation') {
|
if ($type === 'annotation') {
|
||||||
$destPath .= '/Entities';
|
$destPath .= '/Entity';
|
||||||
} else {
|
} else {
|
||||||
$destPath .= '/Resources/config/doctrine/metadata';
|
$destPath .= '/Resources/config/doctrine/metadata';
|
||||||
}
|
}
|
||||||
@ -99,7 +99,7 @@ EOT
|
|||||||
$output->writeln(sprintf('Importing mapping information from "<info>%s</info>" entity manager', $emName));
|
$output->writeln(sprintf('Importing mapping information from "<info>%s</info>" entity manager', $emName));
|
||||||
foreach ($metadata as $class) {
|
foreach ($metadata as $class) {
|
||||||
$className = $class->name;
|
$className = $class->name;
|
||||||
$class->name = $namespace.'\\'.$bundleClass.'\\Entities\\'.$className;
|
$class->name = $namespace.'\\'.$bundleClass.'\\Entity\\'.$className;
|
||||||
if ($type === 'annotation') {
|
if ($type === 'annotation') {
|
||||||
$path = $destPath.'/'.$className.'.php';
|
$path = $destPath.'/'.$className.'.php';
|
||||||
} else {
|
} else {
|
||||||
|
@ -89,7 +89,7 @@ path for the **GuestbookBundle** we created above:
|
|||||||
Any files found in here that have a suffix of **.dcm.xml** (or whatever
|
Any files found in here that have a suffix of **.dcm.xml** (or whatever
|
||||||
mapping_driver you picked) are used as your entities mapping information.
|
mapping_driver you picked) are used as your entities mapping information.
|
||||||
|
|
||||||
In the **GuestbookBundle** we have a file named **Bundle.GuestbookBundle.Entities.Entry.dcm.xml**
|
In the **GuestbookBundle** we have a file named **Bundle.GuestbookBundle.Entity.Entry.dcm.xml**
|
||||||
which contains the following XML:
|
which contains the following XML:
|
||||||
|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
@ -99,7 +99,7 @@ which contains the following XML:
|
|||||||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||||
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||||
|
|
||||||
<entity name="Bundle\GuestbookBundle\Entities\Entry" table="guestbook_entry">
|
<entity name="Bundle\GuestbookBundle\Entity\Entry" table="guestbook_entry">
|
||||||
|
|
||||||
<id name="id" type="integer" column="id">
|
<id name="id" type="integer" column="id">
|
||||||
<generator strategy="AUTO"/>
|
<generator strategy="AUTO"/>
|
||||||
@ -121,13 +121,13 @@ mapping information with the command:
|
|||||||
|
|
||||||
$ php console doctrine:generate:entities
|
$ php console doctrine:generate:entities
|
||||||
|
|
||||||
Now if you have a look in the bundles **Entities** directory you will see a new
|
Now if you have a look in the bundles **Entity** directory you will see a new
|
||||||
file named **Entry.php** with some code like the following:
|
file named **Entry.php** with some code like the following:
|
||||||
|
|
||||||
[php]
|
[php]
|
||||||
// Bundle/GuestbookBundle/Entities/Entry.php
|
// Bundle/GuestbookBundle/Entity/Entry.php
|
||||||
|
|
||||||
namespace Bundle\GuestbookBundle\Entities;
|
namespace Bundle\GuestbookBundle\Entity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Entity
|
* @Entity
|
||||||
@ -214,7 +214,7 @@ You can easily generate a new Doctrine entity for a bundle by using the
|
|||||||
$ php console doctrine:generate:entity "Bundle\MySampleBundle" "User\Group" --fields="name:string(255) description:text"
|
$ php console doctrine:generate:entity "Bundle\MySampleBundle" "User\Group" --fields="name:string(255) description:text"
|
||||||
|
|
||||||
Now if you have a look inside the bundle you will see that you have a **Group** class
|
Now if you have a look inside the bundle you will see that you have a **Group** class
|
||||||
located here **Bundle/MySampleBundle/Entities/User/Group.php**.
|
located here **Bundle/MySampleBundle/Entity/User/Group.php**.
|
||||||
|
|
||||||
Now you can customize the mapping information for the entity by editing the metadata
|
Now you can customize the mapping information for the entity by editing the metadata
|
||||||
information inside **Bundle/MySampleBundle/Resources/config/doctrine/metadata** and
|
information inside **Bundle/MySampleBundle/Resources/config/doctrine/metadata** and
|
||||||
|
Reference in New Issue
Block a user