Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error running doctrine:generate:entities command when using timestampable #37

Open
DanSmith83 opened this issue May 24, 2016 · 8 comments
Labels

Comments

@DanSmith83
Copy link

I'm getting the following error when trying to run this command for an entity using timestampable:

[ErrorException]
Argument 1 passed to LaravelDoctrine\Fluent\Extensions\Gedmo\AbstractTrackingExtension::__construct() must be an instance of LaravelDoctrine\Fluent\Extensions\ExtensibleClass
Metadata, instance of Doctrine\ORM\Mapping\ClassMetadata given, called in /home/vagrant/code/application/vendor/laravel-doctrine/fluent/src/Extensions/Gedmo/Timestampable.php
on line 22

Mapping defined as follows:

public function mapFor()
{
    return Article::class;
}

public function map(Fluent $builder)
{
    $builder->increments('id');
    $builder->string('title');
    $builder->timestamps();
}
@patrickbrouwers
Copy link
Contributor

Are you using it standalone or with Laravel Doctrine ORM?

@DanSmith83
Copy link
Author

With Laravel Doctrine ORM

@patrickbrouwers
Copy link
Contributor

Are you running on the latest version? Because this should be automatically handled by the LD-ORM.
Can you paste the version of ORM and Fluent from the composer.lock?

@DanSmith83
Copy link
Author

"name": "laravel-doctrine/orm",
"version": "1.1.10",
"source": {
"type": "git",
"url": "https://github.com/laravel-doctrine/orm.git",
"reference": "6a3a0743bb1f4860a7e3cb220e502156dee5b985"
},

"name": "laravel-doctrine/fluent",
"version": "1.1.3",
"source": {
"type": "git",
"url": "https://github.com/laravel-doctrine/fluent.git",
"reference": "de6a6cda447a8c0177281ce14ad75f295361cf97"
},

@patrickbrouwers
Copy link
Contributor

Can you see what it does at this line:

vendor/laravel-doctrine/orm/src/EntityManagerFactory.php:153

It should set the ExtensibleClassMetadata

@DanSmith83
Copy link
Author

The code on that line is:

$configuration->setClassMetadataFactoryName($metadata->getClassMetadataFactoryName());

Running dd on get getClassMetadataFactoryName method returns correctly:

LaravelDoctrine\Fluent\Extensions\ExtensibleClassMetadataFactory

I looked at the command, and the error seemed to get generated by the line:

$cmf->getAllMetadata();

I've updated the line DisconnectedClassMetadataFactory.php:39 from:

class DisconnectedClassMetadataFactory extends ClassMetadataFactory

to

class DisconnectedClassMetadataFactory extends ExtensibleClassMetadataFactory

It seems to work OK now.

@patrickbrouwers
Copy link
Contributor

@guiwoda Any idea what we can do about this?

@guiwoda
Copy link
Contributor

guiwoda commented May 25, 2016

@patrickbrouwers the problem seems to be at this line: https://github.com/laravel-doctrine/orm/blob/1.1/src/Console/GenerateEntitiesCommand.php#L50

But ORM doesn't know it needs an ExtensibleClassMetadataFactory. We couldinject it on the command and let fluent override the injection somehow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants