pomm-project / pomm-bundle

Pomm2 bundle for Symfony
81 stars 31 forks source link

BaseGenerator::__construct() must be an instance of PommProject\ModelManager\Session #38

Closed GromNaN closed 9 years ago

GromNaN commented 9 years ago

I'm trying to install the PommBundle (latest version).

Here is my config:

pomm:
    configuration:
        redshift:
            dsn: 'pgsql://%redshift.username%:%redshift.password%@%redshift.host%:5439/%redshift.database%'
    logger:
        service: '@logger'

When running the following command I get an exception:

php console pomm:generate:relation-all -d src/ -a 'PublicationBundle\Model' redshift client
  [Symfony\Component\Debug\Exception\ContextErrorException]
  Catchable Fatal Error: Argument 1 passed to PommProject\ModelManager\Generator\BaseGenerator::__construct() must be an instance of PommProject\ModelManager\Session, 
  instance of PommProject\Foundation\Session given, called in vendor/pomm-project/cli/sources/lib/Command/GenerateForRelation.php on line 76 and defined

Is there something to configure for the class:session_builder ? This config is in the Configuration class, but I don't find the expected value.

webaaz commented 9 years ago

It's a known bug since the last version of the model manager. We're working on a fix. /ping @sanpii @chanmix51

sanpii commented 9 years ago

Is there something to configure for the class:session_builder ?

Yes, as you can see in the README:

        redshift:
            dsn: 'pgsql://%redshift.username%:%redshift.password%@%redshift.host%:5439/%redshift.database%'
            class:session_builder: '\PommProject\ModelManager\SessionBuilder'
GromNaN commented 9 years ago

Thanks. I had copied the 1st configured line of the README.

webaaz commented 9 years ago

So, the problem comes from the configuration. You need the session_builder parameter to use the generators. If custom session_builder is not defined, the default one is a foundation/sessionBuilder, and generators need modelManager/sessionBuilder

GromNaN commented 9 years ago

I've submitted a patch to set the default config: https://github.com/pomm-project/pomm-bundle/pull/39/files

webaaz commented 9 years ago

There's already a default value in PommProject\Foundation\Pomm, but this way looks fine to override it cleanly.

webaaz commented 9 years ago

I've done it the same way on ZF2 Pomm Module