not extending model..

Anonymous avatarAnonymous created an issue

Im trying to extend the FOS Propel User class;

app/config,yml imports: - { resource: parameters.yml } - { resource: security.yml } - { resource: @GlorpenPropelBundle/Resources/config/config.yml }

fos_user: db_driver: propel firewall_name: main user_class: Eyee\UserBundle\Propel\User group: group_class: Eyee\UserBundle\Propel\Group

glorpen_propel: extended_models: FOS\UserBundle\Propel\User: Eyee\UserBundle\Propel\User

This doesn't do anything..

After register; it returns the right Model (my own User.php). but after login $user returns: FOS/UserBundle/Propel/User

Also without Glorpen Propel... it doesnt seem to do anything. Must I do anything else except add this config lines to config.yml ?

Comments (18)

  1. chris087

    Its seems like 'glorpen_propel' ist active, . when i make a typo in config.yml , like:

    propel: build_properties: propel.behavior.extend.classXXXX: 'vendor.glorpen.propel-bundle.Glorpen.Propel.PropelBundle.Behaviors.ExtendBehavior' propel.behavior.default: "extend"

    it doest give any error (cleaned cache)

    Appkernel:

    public function registerBundles()
    {
        $bundles = array(
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
            new Symfony\Bundle\SecurityBundle\SecurityBundle(),
            new Symfony\Bundle\TwigBundle\TwigBundle(),
            new Symfony\Bundle\MonologBundle\MonologBundle(),
            new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
            new Symfony\Bundle\AsseticBundle\AsseticBundle(),
            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
            new Propel\PropelBundle\PropelBundle(),
            new Smirik\PropelAdminBundle\SmirikPropelAdminBundle(),
            new Smirik\BootstrapBundle\SmirikBootstrapBundle(),
            new Glorpen\Propel\PropelBundle\GlorpenPropelBundle(),
            new Acme\HelloBundle\AcmeHelloBundle(),
            new Eyee\SmaCastBundle\EyeeSmaCastBundle(),
            new FOS\UserBundle\FOSUserBundle(),
            new Eyee\UserBundle\EyeeUserBundle()
        );
    

    config.yml:

    imports: - { resource: parameters.yml } - { resource: security.yml }

    fos_user: db_driver: propel firewall_name: main user_class: Eyee\UserBundle\Propel\User group: group_class: Eyee\UserBundle\Propel\Group

    propel: build_properties: propel.behavior.extend.class: 'vendor.glorpen.propel-bundle.Glorpen.Propel.PropelBundle.Behaviors.ExtendBehavior' propel.behavior.default: "extend"

    glorpen_propel: extended_models: FOS\UserBundle\Propel\User: Eyee\UserBundle\Propel\User

    propel: path: "%kernel.root_dir%/../vendor/propel" phing_path: "%kernel.root_dir%/../vendor/phing"

    dbal:
        driver:               %database_driver%
        user:                 %database_user%
        password:             %database_password%
        dsn:                  %database_driver%:host=%database_host%;dbname=%database_name%;charset=UTF8
        options:              {}
        attributes:           {}
    
  2. Arkadiusz Dzięgiel

    I've created example project with latest stable propel & propel-bundle and after configuring, clearing cache and building everything works as expected.

    Try to going back to importing conf in config.yml - { resource: @GlorpenPropelBundle/Resources/config/config.yml } and removing added before build_properties etc.

    Then you can change class path in GlorpenPropelBundle/Resources/config/config.yml - propel.behavior.extend.class: 'vendor.glorpen.propel-bundle.Glorpen.Propel.PropelBundle.Behaviors.ExtendBehavior' to something invalid to cause error.

  3. chris087

    Ok..

    Changed app.config like this:

    !yml

    imports: - { resource: parameters.yml } - { resource: security.yml } - { resource: @GlorpenPropelBundle/Resources/config/config.yml }

    fos_user: db_driver: propel firewall_name: main user_class: Eyee\UserBundle\Propel\User group: group_class: Eyee\UserBundle\Propel\Group

    glorpen_propel: extended_models: FOS\UserBundle\Propel\User: Eyee\UserBundle\Propel\User

    propel: path: "%kernel.root_dir%/../vendor/propel" phing_path: "%kernel.root_dir%/../vendor/phing"

    dbal:
        driver:               %database_driver%
        user:                 %database_user%
        password:             %database_password%
        dsn:                  %database_driver%:host=%database_host%;dbname=%database_name%;charset=UTF8
        options:              {}
        attributes:           {}
    

    ```

    In GlorpenPropelBundle/Resources/config/config.yml:

    propel.behavior.extend.class: 'vendor.glorpen.propel-bundle.Glorpen.Propel.PropelBundle.Behaviors.ExtendBe3453454ffhavior

    Cleaned cache.. Nothing happends.. no errors.

    Im trying to reinstall the bundle.. Im confused..

  4. Arkadiusz Dzięgiel

    Try to rebuild model with broken classpath - the error should emerge - I've got big red "[Propel] Error".

    I assume that you don't have custom build_properties defined in config.yml or config_dev.yml ?

  5. chris087

    I reinstalled the bundle, (and I dont have build_properties in config.yml)

    Config.yml:

    imports: - { resource: parameters.yml } - { resource: security.yml } - { resource: @GlorpenPropelBundle/Resources/config/config.yml }

    In GlorpenPropelBundle/Resources/config/config.yml:

    propel.behavior.extend.class: 'vendor.glorpen.propel-bundle.Glorpen.Propel.PropelBundle.Behaviors.ExtendBe3453454ffhavior

    -sh-4.1$ php app/console propel:build

    [Propel] Error

    An error has occured during the "om" task process. To get more details, run the command with the "--verbose" option.

    Error occurs on build, so I assume the bundle is used correctly. I can mail you my bundle, to have a look?

  6. chris087

    <?php

    namespace Eyee\SmaCastBundle\Controller;

    use Eyee\SmaCastBundle\Controller\Base\AdminUserController as BaseController;

    use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

    use FOS\UserBundle\FOSUserEvents; use FOS\UserBundle\Event\FormEvent; use FOS\UserBundle\Event\GetResponseUserEvent; use FOS\UserBundle\Event\UserEvent; use FOS\UserBundle\Event\FilterUserResponseEvent; use Symfony\Component\DependencyInjection\ContainerAware; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Security\Core\Exception\AccessDeniedException; use FOS\UserBundle\Model\UserInterface; use FOS\UserBundle\Model\GroupableInterface; use FOS\UserBundle\Propel\GroupQuery;

    class AdminUserController extends BaseController {

    public function indexAction($page = false)
    {
     //  $c = $this->container->get('security.context')->getToken();
      echo "<pre>";
      print_r($this->getUser()); exit;
    

    ->

    FOS\UserBundle\Propel\User Object ( [plainPassword:protected] => [startCopy:protected] => [id:protected] => 1

    :( :(

  7. Arkadiusz Dzięgiel

    Ok, so from what i see:

    You replaced fos_user table with own which is generated in Eyee\UserBundle\Propel, therefore FOS\UserBundle\Propel\* is broken (map and om classes are not generated there) and should not be used. Delete FOS\UserBundle\Propel\om and map dirs to see :)

    I think you have 2 choices:

    you could seek help in FOSUserBundle documentation about extending whole schema (which you are doing)

    or apply propel single inheritance pattern, in that case use of GlorpenPropelBundle is a good choice.

  8. chris087

    what do you mean with:

    or apply propel single inheritance pattern, in that case use of GlorpenPropelBundle is a good choice.

    \ ?

  9. chris087

    I just want to use my User.php class instead of FOSuserbundle, in symfony 1.4 -> 2 seconds , im already working now for over a week to manage such extreme simple thing in SYmfony 2.

  10. Arkadiusz Dzięgiel

    If you want to extend user class, don't replace fos schema.xml, just use my bundle.

    If you want add some fields to user table, I believe the best practice is to create one-to-one relation with user table and your data table.

  11. chris087

    I dont want to add extra fields (for now) but want the flexibility of doing it maybe in future, thats why I use custom schema.yml (in own bundle)

  12. chris087

    I removed my own schema.yml and use the default FOSuserbundle one.. Its working now:) thank you !

    And for future, the one on one relation is best I think (another table linked to fos_user_id)

  13. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.