symfony/symfony — Issue #3189: doctrine:generate:entities & AbstractFileDriver.php
Author: nezuvian
Created: 2012-01-25 10:23:41+00:00
State: open

Hi!

I came across with the following error message when I tried to generate classes from yaml:
###### Notice: Undefined index: Acme\TestBundle\Entity\Category in C:\xampp\htdocs\symfony\vendor\doctrine\lib\Doctrine\ORM\Mapping\Driver\AbstractFileDriver-php line 121

After some debugging I was able to get around this error by adding these two lines to the AbstractFileDriver.php getElement function. Here is the new code:

```php
public function getElement($className)
{
$result = this->_loadMappingFile($this->_findMappingFile($className));
$className = explode(DIRECTORY_SEPARATOR, $className);
$className = $className[count($className)-1];
return $result[$className];
}
```
I'm guessing this is not the right way to solve this problem :) So my question is: what's causing this error and how can I fix it without meddling with core classes?

I'm using Symfony 2.0.9. For reference here is my yaml file content:

```php
Category:
type: entity
table: null
fields:
id:
type: integer
id: true
generator:
strategy: IDENTITY
name:
type: string
length: '255'
unique: true
lifecycleCallbacks: { }
```