IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Symfony PHP Discussion :

Problème d'utilisation d'un UserRepository personnel


Sujet :

Symfony PHP

  1. #1
    Nouveau Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2013
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Octobre 2013
    Messages : 15
    Points : 1
    Points
    1
    Par défaut Problème d'utilisation d'un UserRepository personnel
    Bonjour à tous,

    Je développe actuellement un site sous Symfony2. Je rencontre un problème avec la mise en place de la sécurité. En effet, j'aimerai restreindre l'accès à une partie "membre" afin que seuls les utilisateurs stockés en base de données puissent y accéder. J'ai donc suivi le tutoriel fourni par le Symfony cookbook (http://symfony.com/fr/doc/current/co..._provider.html).

    Mais lorsque je teste, l'erreur
    EntityRepository must implement UserInterface
    survient. J'ai pourtant créé mon propre "MembreRepository" qui implémente bien UserInterface. J'ai également indiqué à Doctrine d'utiliser MembreRepository (donc celui que j'ai créé) grâce à l'annotation @ORM\Entity(repositoryClass="Design\InitializrBundle\Entity\MembreRepository") dans mon entité.

    D'après ce que j'en comprend, il semblerait que Doctrine ignore simplement cette annotation et utilise son UserRepository par défaut..

    Quelqu'un aurait-il une idée pour m'aider à résoudre ou au moins à comprendre ce problème?

  2. #2
    Membre averti
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mai 2007
    Messages
    643
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Mai 2007
    Messages : 643
    Points : 305
    Points
    305
    Par défaut
    Il me semble bien qu'il existe des routing automatique qui partent du principe que la classe repository d'une Entity est bien le nom de l'entité + Repository et le tout attaché.

    Ca me parait bizarre et sujet à incompréhension de fournir un repository avec un nom différent. Mais il est également vraiment que Doctrine nous demande notre avis donc c'est sujet à incompréhension.

    Enfin même si ca ne répond pas exactement à ta question essai quand même de ne rien changer à ton code mise à part le nom afin de voir si le problème viens bien de là peut-être...

  3. #3
    Membre habitué
    Ingénieur d'études et de développement
    Inscrit en
    Juin 2009
    Messages
    112
    Détails du profil
    Informations professionnelles :
    Activité : Ingénieur d'études et de développement
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juin 2009
    Messages : 112
    Points : 154
    Points
    154
    Par défaut
    Bonjour,

    fais voir ton security.yml stp

  4. #4
    Nouveau Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2013
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Octobre 2013
    Messages : 15
    Points : 1
    Points
    1
    Par défaut
    Salut,

    @miltone : Mon repository hérite directement de EntityRepository donc le renommer n'a pas changé grand chose, le même message d'erreur survient

    Voici mon security.yml

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    # app/config/config.yml
    security:
        firewalls:
            dev:
                pattern:  ^/(_(profiler|wdt)|css|images|js)/
                security: false
     
            secured_area:
                pattern:    ^/
                anonymous: ~
                http_basic:
                    realm: "Secured Demo Area"
                form_login:
                    login_path:  /site/login
                    check_path:  /site/login_check
                    provider: chain_provider
                logout:
                    path:   /site/logout
                    target: /site/accueil
     
        # indique les roles necessaires pour acceder aux url indiquees
        access_control:
            - { path: ^/site/membre, roles: ROLE_USER }
            - { path: ^/site/admin, roles: ROLE_ADMIN }
            - { path: ^/site/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
     
     
        # indique la hierarchie des roles	
        role_hierarchy:
            ROLE_ADMIN:       ROLE_USER
            ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
     
        # les fournisseurs d'entite ou seront recuperes les utilisateurs et
        # l'administrateur
        providers:
            chain_provider:
                chain :
                    providers: [in_memory, user_db]
            user_db:
                entity: { class: Design\InitializrBundle\Entity\Membre }
            in_memory:
                memory:
                    users:
                        admin: { password: kitten, roles: 'ROLE_ADMIN' }
     
        # encodeurs utiliser pour chiffrer les mots de passe
        encoders:
            Symfony\Component\Security\Core\User\User: plaintext
            Design\InitializrBundle\Entity\Membre: sha512

  5. #5
    Nouveau Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2013
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Octobre 2013
    Messages : 15
    Points : 1
    Points
    1
    Par défaut
    Salut,

    Une idée quelqu'un ? Car j'avoue ne pas vraiment savoir quoi faire...
    En parcourant un peu plus la doc, je me suis dit que mon erreur venait peut être d'un oubli de déclaration de mon Repository dans les services?

    Voici mon fichier services.yml :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    # src/Design/InitializrBundle/Resources/config/services.yml
    parameters:
        design_initializr.membrerepository.class: Design\InitializrBundle\Entity\MembreRepository
     
    services:
        design_initializr.membrerepository:
            class: %design_initializr.membrerepository.class%
    Et mon security.yml avec le service:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    security:
        #...
        providers:
            chain_provider:
                chain :
                    providers: [in_memory, user_db]
            user_db:
                id: design_initializr.membrerepository
                #entity: { class: Design\InitializrBundle\Entity\Membre }
            in_memory:
                memory:
                    users:
                        admin: { password: pass, roles: 'ROLE_ADMIN' }
        #...
    Une autre erreur survient maintenant, je n'arrive plus à lancer la commande cache:clear ...

    Si personne n'a d'idée je vais simplement recommencer la partie sécurité de 0, mais j'aimerais quand même essayer de comprendre mon erreur

    Cordialement

  6. #6
    Membre averti
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mai 2007
    Messages
    643
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Mai 2007
    Messages : 643
    Points : 305
    Points
    305
    Par défaut
    que te signal l'erreur du cache:clear ?

  7. #7
    Nouveau Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2013
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Octobre 2013
    Messages : 15
    Points : 1
    Points
    1
    Par défaut
    l'erreur du cache:clear m'indique qu'il manque un argument lors de la création du repository si j'ai bien compris

    je suis un peu confus en lisant la doc, en effet ici on peut lire que
    dire à Symfony d'utiliser le nouveau fournisseur d'entité personnalisé à la place du fournisseur d'entité Doctrine générique [...] est facile à réaliser en supprimant le champ property dans la section security.providers.administrators.entity du fichier security.yml
    alors que , on nous dis qu'il faut déclarer le repository en tant que service etc...

    Voici le message du cache:clear
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    PHP Warning:  Missing argument 1 for Doctrine\ORM\EntityRepository::__construct(), called in C:\wamp\www\Symfony-Initializr\app\cache\de_\ap_DevDebugProjectContainer.php on line 1417 and defined in C:\wamp\www\Symfony-Initializr\vendor\doctrine\orm\lib\Doctrine\ORM\EntityRepository.php on line 67
    PHP Stack trace:
    PHP   1. {main}() C:\wamp\www\Symfony-Initializr\app\console:0
    PHP   2. Symfony\Component\Console\Application->run() C:\wamp\www\Symfony-Initializr\app\console:27
    PHP   3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:121
    PHP   4. Symfony\Component\Console\Application->doRun() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Console\Application.php:96
    PHP   5. Symfony\Component\Console\Application->doRunCommand() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:191
    PHP   6. Symfony\Component\Console\Command\Command->run() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:888
    PHP   7. Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->execute() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Component\Console\Command\Command.php:241
    PHP   8. Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->warmup() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand.php:83
    PHP   9. Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate->warmUp() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand.php:120
    PHP  10. Symfony\Bundle\AsseticBundle\CacheWarmer\AssetManagerCacheWarmer->warmUp() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate.php:48
    PHP  11. Symfony\Component\DependencyInjection\Container->get() C:\wamp\www\Symfony-Initializr\vendor\symfony\assetic-bundle\Symfony\Bundle\AsseticBundle\CacheWarmer\AssetManagerCacheWarmer.php:33
    PHP  12. ap_DevDebugProjectContainer->getAssetic_AssetManagerService() C:\wamp\www\Symfony-Initializr\app\bootstrap.php.cache:2033
    PHP  13. Symfony\Component\DependencyInjection\Container->get() C:\wamp\www\Symfony-Initializr\app\cache\de_\ap_DevDebugProjectContainer.php:297
    PHP  14. ap_DevDebugProjectContainer->getTwigService() C:\wamp\www\Symfony-Initializr\app\bootstrap.php.cache:2033
    PHP  15. Symfony\Component\DependencyInjection\Container->get() C:\wamp\www\Symfony-Initializr\app\cache\de_\ap_DevDebugProjectContainer.php:2903
    PHP  16. ap_DevDebugProjectContainer->getSecurity_ContextService() C:\wamp\www\Symfony-Initializr\app\bootstrap.php.cache:2033
    PHP  17. Symfony\Component\DependencyInjection\Container->get() C:\wamp\www\Symfony-Initializr\app\cache\de_\ap_DevDebugProjectContainer.php:1802
    PHP  18. ap_DevDebugProjectContainer->getSecurity_Authentication_ManagerService() C:\wamp\www\Symfony-Initializr\app\bootstrap.php.cache:2033
    PHP  19. Symfony\Component\DependencyInjection\Container->get() C:\wamp\www\Symfony-Initializr\app\cache\de_\ap_DevDebugProjectContainer.php:3220
    PHP  20. ap_DevDebugProjectContainer->getSecurity_User_Provider_Concrete_ChainProviderService() C:\wamp\www\Symfony-Initializr\app\bootstrap.php.cache:2033
    PHP  21. Symfony\Component\DependencyInjection\Container->get() C:\wamp\www\Symfony-Initializr\app\cache\de_\ap_DevDebugProjectContainer.php:3275
    PHP  22. ap_DevDebugProjectContainer->getMembreRepositoryService() C:\wamp\www\Symfony-Initializr\app\bootstrap.php.cache:2033
    PHP  23. Doctrine\ORM\EntityRepository->__construct() C:\wamp\www\Symfony-Initializr\app\cache\de_\ap_DevDebugProjectContainer.php:1417
    PHP Catchable fatal error:  Argument 2 passed to Doctrine\ORM\EntityRepository::__construct() must be an instance of Doctrine\ORM\Mapping\ClassMetadata, none given, called in C:\wamp\www\Symfony-Initializr\app\cache\de_\ap_DevDebugProjectContainer.php on line 1417 and defined in C:\wamp\www\Symfony-Initializr\vendor\doctrine\orm\lib\Doctrine\ORM\EntityRepository.php on line 67
    PHP Stack trace:
    PHP   1. {main}() C:\wamp\www\Symfony-Initializr\app\console:0
    PHP   2. Symfony\Component\Console\Application->run() C:\wamp\www\Symfony-Initializr\app\console:27
    PHP   3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:121
    PHP   4. Symfony\Component\Console\Application->doRun() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Console\Application.php:96
    PHP   5. Symfony\Component\Console\Application->doRunCommand() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:191
    PHP   6. Symfony\Component\Console\Command\Command->run() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:888
    PHP   7. Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->execute() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Component\Console\Command\Command.php:241
    PHP   8. Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->warmup() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand.php:83
    PHP   9. Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate->warmUp() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand.php:120
    PHP  10. Symfony\Bundle\AsseticBundle\CacheWarmer\AssetManagerCacheWarmer->warmUp() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate.php:48
    PHP  11. Symfony\Component\DependencyInjection\Container->get() C:\wamp\www\Symfony-Initializr\vendor\symfony\assetic-bundle\Symfony\Bundle\AsseticBundle\CacheWarmer\AssetManagerCacheWarmer.php:33
    PHP  12. ap_DevDebugProjectContainer->getAssetic_AssetManagerService() C:\wamp\www\Symfony-Initializr\app\bootstrap.php.cache:2033
    PHP  13. Symfony\Component\DependencyInjection\Container->get() C:\wamp\www\Symfony-Initializr\app\cache\de_\ap_DevDebugProjectContainer.php:297
    PHP  14. ap_DevDebugProjectContainer->getTwigService() C:\wamp\www\Symfony-Initializr\app\bootstrap.php.cache:2033
    PHP  15. Symfony\Component\DependencyInjection\Container->get() C:\wamp\www\Symfony-Initializr\app\cache\de_\ap_DevDebugProjectContainer.php:2903
    PHP  16. ap_DevDebugProjectContainer->getSecurity_ContextService() C:\wamp\www\Symfony-Initializr\app\bootstrap.php.cache:2033
    PHP  17. Symfony\Component\DependencyInjection\Container->get() C:\wamp\www\Symfony-Initializr\app\cache\de_\ap_DevDebugProjectContainer.php:1802
    PHP  18. ap_DevDebugProjectContainer->getSecurity_Authentication_ManagerService() C:\wamp\www\Symfony-Initializr\app\bootstrap.php.cache:2033
    PHP  19. Symfony\Component\DependencyInjection\Container->get() C:\wamp\www\Symfony-Initializr\app\cache\de_\ap_DevDebugProjectContainer.php:3220
    PHP  20. ap_DevDebugProjectContainer->getSecurity_User_Provider_Concrete_ChainProviderService() C:\wamp\www\Symfony-Initializr\app\bootstrap.php.cache:2033
    PHP  21. Symfony\Component\DependencyInjection\Container->get() C:\wamp\www\Symfony-Initializr\app\cache\de_\ap_DevDebugProjectContainer.php:3275
    PHP  22. ap_DevDebugProjectContainer->getMembreRepositoryService() C:\wamp\www\Symfony-Initializr\app\bootstrap.php.cache:2033
    PHP  23. Doctrine\ORM\EntityRepository->__construct() C:\wamp\www\Symfony-Initializr\app\cache\de_\ap_DevDebugProjectContainer.php:1417
    Mon fichier MembreRepository.php est, pour l'instant, le même (aux noms près) que celui du cookbook (lien ici)

    Cordialement

  8. #8
    Membre régulier Avatar de DarckCrystale
    Femme Profil pro
    Développeuse Web
    Inscrit en
    Juin 2013
    Messages
    71
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 32
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Développeuse Web
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2013
    Messages : 71
    Points : 109
    Points
    109
    Par défaut
    Bonjour,

    Je ne sais pas si ce que je peux rajouter sera pertinent, mais j'ai suivi un autre tutoriel que celui du site officiel pour la gestion des rôles, et j'y suis arrivée sans problème.

    Si le lien disparaît, c'est symfony2 rôles Utiliser des utilisateurs de la base de données dans google.

    Pour ce qui est du problème plus précisément :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    # app/config/config.yml
    security:
       #....
     
            secured_area:
                #......
                form_login:
                    #....
                    provider: chain_provider
     
        #.....
        # les fournisseurs d'entite ou seront recuperes les utilisateurs et
        # l'administrateur
        providers:
            chain_provider:
                chain :
                    providers: [in_memory, user_db]
            #.......
    Je pense que le provider chain_provider déclaré comme fournisseur d'utilisateurs est mal configuré plus bas dans le security.yml : le tuto symfony2 le dit :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    # app/config/security.yml
    security:
        # ...
        providers:
            administrators:
                entity: { class: AcmeUserBundle:User }
        # ...
    Pourquoi ne pas avoir copié collé le code en ne remplaçant pas 'juste' AcmeUserBundle:User par le nom de l'entité qui chez vous gère les utilisateurs ?

  9. #9
    Nouveau Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2013
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Octobre 2013
    Messages : 15
    Points : 1
    Points
    1
    Par défaut
    Bonjour,

    Pour te répondre, j'ai mis le chain provider car le compte admin sera stocké en dur dans le provider "in_memory", j'ai donc suivi un tuto (très probablement le cookbook d'aileurs), dans lequel une section expliquait comment avoir à la fois des utilisateurs en dur (mon admin par ex) et des utilisateurs depuis la base de données.
    D'ailleurs pour l'instant, la connexion avec l'admin fonctionne.

    D'ailleurs après avoir modifié quelque peu mon services.yml, le cache:clear annonce une autre erreur

    Services.yml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    # src/Design/InitializrBundle/Resources/config/services.yml
    parameters:
        membre_repository.class: Design\InitializrBundle\Entity\MembreRepository
        membre_repository.factory_service: doctrine.orm.default_entity_manager 
        membre_repository.factory_method: getRepository 
        membre_repository.arguments: ['DesignInitializrBundle:Membre']
     
    services: 
        membre_repository:
            class: %membre_repository.class%
            factory_service: %membre_repository.factory_service%
            factory_method: %membre_repository.factory_method%
            arguments: %membre_repository.arguments%
    Erreur du cache:clear:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    PHP Catchable fatal error:  Argument 1 passed to Symfony\Component\DependencyInjection\Definition::setArguments() must be of the type array, string given, called in C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Loader\YamlFileLoader.php on line 192 and defined in C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Definition.php on line 180
    PHP Stack trace:
    PHP   1. {main}() C:\wamp\www\Symfony-Initializr\app\console:0
    PHP   2. Symfony\Component\Console\Application->run() C:\wamp\www\Symfony-Initializr\app\console:27
    PHP   3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:121
    PHP   4. Symfony\Component\HttpKernel\Kernel->boot() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Console\Application.php:70
    PHP   5. Symfony\Component\HttpKernel\Kernel->initializeContainer() C:\wamp\www\Symfony-Initializr\app\bootstrap.php.cache:2272
    PHP   6. Symfony\Component\HttpKernel\Kernel->buildContainer() C:\wamp\www\Symfony-Initializr\app\bootstrap.php.cache:2492
    PHP   7. AppKernel->registerContainerConfiguration() C:\wamp\www\Symfony-Initializr\app\bootstrap.php.cache:2540
    PHP   8. Symfony\Component\Config\Loader\DelegatingLoader->load() C:\wamp\www\Symfony-Initializr\app\AppKernel.php:34
    PHP   9. Symfony\Component\DependencyInjection\Loader\YamlFileLoader->load() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Component\Config\Loader\DelegatingLoader.php:52
    PHP  10. Symfony\Component\DependencyInjection\Loader\YamlFileLoader->parseImports() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Loader\YamlFileLoader.php:55
    PHP  11. Symfony\Component\Config\Loader\FileLoader->import() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Loader\YamlFileLoader.php:98
    PHP  12. Symfony\Component\DependencyInjection\Loader\YamlFileLoader->load() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Component\Config\Loader\FileLoader.php:86
    PHP  13. Symfony\Component\DependencyInjection\Loader\YamlFileLoader->parseImports() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Loader\YamlFileLoader.php:55
    PHP  14. Symfony\Component\Config\Loader\FileLoader->import() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Loader\YamlFileLoader.php:98
    PHP  15. Symfony\Component\DependencyInjection\Loader\YamlFileLoader->load() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Component\Config\Loader\FileLoader.php:86
    PHP  16. Symfony\Component\DependencyInjection\Loader\YamlFileLoader->parseDefinitions() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Loader\YamlFileLoader.php:68
    PHP  17. Symfony\Component\DependencyInjection\Loader\YamlFileLoader->parseDefinition() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Loader\YamlFileLoader.php:115
    PHP  18. Symfony\Component\DependencyInjection\Definition->setArguments() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Loader\YamlFileLoader.php:192
    Si je comprend bien cette erreur, un des arguments dans services.yml contient une erreur. Une idée quelqu'un?

    Corduialelmen

  10. #10
    Membre régulier Avatar de DarckCrystale
    Femme Profil pro
    Développeuse Web
    Inscrit en
    Juin 2013
    Messages
    71
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 32
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Développeuse Web
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2013
    Messages : 71
    Points : 109
    Points
    109
    Par défaut
    Si la connexion avec l'admin fonctionne, mais pas celle avec l'utilisateur, je comprends mieux ton premier post.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    # les fournisseurs d'entite ou seront recuperes les utilisateurs et
        # l'administrateur
        providers:
            chain_provider:
                chain :
                    providers: [in_memory, user_db]
            user_db:
                entity: { class: Design\InitializrBundle\Entity\Membre }
            in_memory:
                memory:
                    users:
                        admin: { password: kitten, roles: 'ROLE_ADMIN' }
    Manquerait pas une tabulation ?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    # les fournisseurs d'entite ou seront recuperes les utilisateurs et
        # l'administrateur
        providers:
            chain_provider:
                chain :
                    providers: [in_memory, user_db]
                user_db:
                    entity: { class: Design\InitializrBundle\Entity\Membre }
                in_memory:
                    memory:
                        users:
                            admin: { password: kitten, roles: 'ROLE_ADMIN' }
    Je ne sais pas si ça joue sur le yaml, et même si l'erreur vient de là, mais je ne comprends pas ce bout de code.

  11. #11
    Nouveau Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2013
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Octobre 2013
    Messages : 15
    Points : 1
    Points
    1
    Par défaut
    Salut,

    J'avais déjà corrigé les tabulations donc le problème ne vient pas de là.

    Pour le code de security.providers de mon security.yml, je l'ai trouvé sur le book/cookbook (ici)

  12. #12
    Nouveau Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2013
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Octobre 2013
    Messages : 15
    Points : 1
    Points
    1
    Par défaut
    Il faut réactualiser la page pour le lien de mon précédent post, l'ancre n'a pas l'air d'être prise en compte,

    Cordialement

  13. #13
    Membre régulier Avatar de DarckCrystale
    Femme Profil pro
    Développeuse Web
    Inscrit en
    Juin 2013
    Messages
    71
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 32
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Développeuse Web
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2013
    Messages : 71
    Points : 109
    Points
    109
    Par défaut
    Ok !

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    # src/Sdz/BlogBundle/Resources/config/services.yml
     
    services:
        sdz_blog.antispam:
            class: Sdz\BlogBundle\Antispam\SdzAntispam
            arguments: [] # Tableau d'arguments
    Nous dit Winzou.

    Est-ce que tu peux essayer de mettre des [ ] autours de l'argument qu'il faudrait mettre en plusieurs exemplaires dans services.yml ?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    services: 
        membre_repository:
            #.....
            arguments: [%membre_repository.arguments%]

  14. #14
    Nouveau Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2013
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Octobre 2013
    Messages : 15
    Points : 1
    Points
    1
    Par défaut
    Salut,

    J'ai enlevé le noeud "parameters" de mon services.yml, le cache:clear est passé
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    # src/Design/InitializrBundle/Resources/config/services.yml
    services: 
        membre_repository:
            class: Design\InitializrBundle\Entity\MembreRepository
            factory_service: doctrine.orm.default_entity_manager
            factory_method: getRepository
            arguments: ["DesignInitializrBundle:Membre"]
    Mais maintenant j'ai l'erreur
    User provider "Doctrine\ORM\EntityRepository" must implement "Symfony\Component\Security\Core\User\UserProviderInterface
    qui s'affiche, quelle que soit la page que j'essaye d'atteindre.
    De retour à la même erreur qu'au début au gros, mais au début cette erreur ne survenait que lors de le validation d'un formulaire d'authentification utilisateur, maintenant c'est tout le temps

    En y réfléchissant un peu, ça semble normal, puisque j'ai défini mon repository en tant que service, il doit donc être instancié au chargement de la page ou quelque chose comme ça.

    Toujours est-il que symfony n'utilise toujours pas le MembreRepository que j'ai créé, mais s'entête encore à utiliser son EntityRepository de base.. Une idée?

    Cordialement

  15. #15
    Nouveau Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2013
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Octobre 2013
    Messages : 15
    Points : 1
    Points
    1
    Par défaut
    Après quelques tests supplémentaires, il s'avère que si j'enlève les parties chain_provider et in_memory de mon security.yml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    providers:
            user_db:
                id: membre_repository # nom du service cree
    le cache:clear ne passe plus, et sort lui aussi l'erreur "... must implement UserProviderInterface"
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    PHP Catchable fatal error:  Argument 1 passed to Symfony\Component\Security\Core\Authentication\Provider\DaoAuthenticationProvider::__construct() must be an instance of Symfony\Component\Security\Core\User\UserProviderInterface, instance of Doctrine\ORM\EntityRepository given, called in C:\wamp\www\Symfony-Initializr\app\cache\de_\ap_DevDebugProjectContainer.php on line 3215 and defined in C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Component\Security\Core\Authentication\Provider\DaoAuthenticationProvider.php on line 43
    PHP Stack trace:
    PHP   1. {main}() C:\wamp\www\Symfony-Initializr\app\console:0
    PHP   2. Symfony\Component\Console\Application->run() C:\wamp\www\Symfony-Initializr\app\console:27
    PHP   3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:121
    PHP   4. Symfony\Component\Console\Application->doRun() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Console\Application.php:96
    PHP   5. Symfony\Component\Console\Application->doRunCommand() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:191
    PHP   6. Symfony\Component\Console\Command\Command->run() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:888
    PHP   7. Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->execute() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Component\Console\Command\Command.php:241
    PHP   8. Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->warmup() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand.php:83
    PHP   9. Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate->warmUp() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand.php:120
    PHP  10. Symfony\Bundle\AsseticBundle\CacheWarmer\AssetManagerCacheWarmer->warmUp() C:\wamp\www\Symfony-Initializr\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate.php:48
    PHP  11. Symfony\Component\DependencyInjection\Container->get() C:\wamp\www\Symfony-Initializr\vendor\symfony\assetic-bundle\Symfony\Bundle\AsseticBundle\CacheWarmer\AssetManagerCacheWarmer.php:33
    PHP  12. ap_DevDebugProjectContainer->getAssetic_AssetManagerService() C:\wamp\www\Symfony-Initializr\app\bootstrap.php.cache:2033
    PHP  13. Symfony\Component\DependencyInjection\Container->get() C:\wamp\www\Symfony-Initializr\app\cache\de_\ap_DevDebugProjectContainer.php:295
    PHP  14. ap_DevDebugProjectContainer->getTwigService() C:\wamp\www\Symfony-Initializr\app\bootstrap.php.cache:2033
    PHP  15. Symfony\Component\DependencyInjection\Container->get() C:\wamp\www\Symfony-Initializr\app\cache\de_\ap_DevDebugProjectContainer.php:2898
    PHP  16. ap_DevDebugProjectContainer->getSecurity_ContextService() C:\wamp\www\Symfony-Initializr\app\bootstrap.php.cache:2033
    PHP  17. Symfony\Component\DependencyInjection\Container->get() C:\wamp\www\Symfony-Initializr\app\cache\de_\ap_DevDebugProjectContainer.php:1800
    PHP  18. ap_DevDebugProjectContainer->getSecurity_Authentication_ManagerService() C:\wamp\www\Symfony-Initializr\app\bootstrap.php.cache:2033
    PHP  19. Symfony\Component\Security\Core\Authentication\Provider\DaoAuthenticationProvider->__construct() C:\wamp\www\Symfony-Initializr\app\cache\de_\ap_DevDebugProjectContainer.php:3215
    Je précise qu'en faisant cela j'ai bien évidemment pensé à changer le nom du provider dans security.firewalls.secured_area.form_login.provider
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    # app/config/security.yml
    security:
        firewalls:
            # ...
                form_login:
                    login_path:  /site/login
                    check_path:  /site/login_check
                    provider: user_db

  16. #16
    Membre actif
    Profil pro
    Inscrit en
    Novembre 2010
    Messages
    168
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2010
    Messages : 168
    Points : 219
    Points
    219
    Par défaut
    tu implementes bien "Symfony\Component\Security\Core\User\UserInterface" et "Symfony\Component\Security\Core\User\UserProviderInterface" ?

  17. #17
    Nouveau Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2013
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Octobre 2013
    Messages : 15
    Points : 1
    Points
    1
    Par défaut
    Oui justement, là est tout le problème.
    Au lieux d'utiliser mon MembreRepository qui hérite de EntityRepository, implémente UserProviderInterface et est indiqué dans l'entité avec l'annotation @ORM\Entity(repositoryClass="..."), Symfony utilise son EntityRepository par défaut (qui lui n'implémente pas UserProviderInterface du coup)

    MembreRepository.php
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    <?php 
    // src/Design/InitializrBundle/Entity/MembreRepository.php
    namespace Design\InitializrBundle\Entity;
     
    use Symfony\Component\Security\Core\User\UserInterface;
    use Symfony\Component\Security\Core\User\UserProviderInterface;
    use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
    use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
    use Doctrine\ORM\EntityRepository;
    use Doctrine\ORM\NoResultException;
     
    class MembreRepository extends EntityRepository implements UserProviderInterface
    {
    	public function loadUserByUsername($username)
    	{
    		$q = $this
    		->createQueryBuilder('u')
    		->where('u.username = :username OR u.email = :email')
    		->setParameter('username', $username)
    		->setParameter('email', $username)
    		->getQuery();
     
    		try {
    			// La méthode Query::getSingleResult() lance une exception
    			// s'il n'y a pas d'entrée correspondante aux critères
    			$user = $q->getSingleResult();
    		} catch (NoResultException $e) {
    			throw new UsernameNotFoundException(sprintf('Unable to find an active user DesignInitializrBundle:User object identified by "%s".', $username), 0, $e);
    		}
     
    		return $user;
    	}
     
    	public function refreshUser(UserInterface $user)
    	{
    		$class = get_class($user);
    		if (!$this->supportsClass($class)) {
    			throw new UnsupportedUserException(
    					sprintf(
    							'Instances of "%s" are not supported.',
    							$class
    					)
    			);
    		}
     
    		return $this->loadUserByUsername($user->getUsername());
    	}
     
    	public function supportsClass($class)
    	{
    		return $this->getEntityName() === $class || is_subclass_of($class, $this->getEntityName());
    	}
    }
    ?>

  18. #18
    Nouveau Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2013
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Octobre 2013
    Messages : 15
    Points : 1
    Points
    1
    Par défaut
    Quelqu'un aurait une idée svp?

  19. #19
    Membre éprouvé
    Homme Profil pro
    Inscrit en
    Juin 2011
    Messages
    725
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juin 2011
    Messages : 725
    Points : 1 050
    Points
    1 050
    Par défaut
    Bonjour,

    On dirait que l'annotation pour personaliser le repository n'est pas pris en compte.
    Que donnes cette commande? la classe est-elle bien MembreRepository?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    app/console container:debug membre_repository
    A tester également dans un controlleur de test:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    $repository = $this->get('doctrine')->getManager()->getRepository("DesignInitializrBundle:Membre");
    echo get_class($repository);exit;
    Une des personnes avait un probleme car l'annotation @ORM\Entity était déclaré AVANT l'annotation @ORM\Table

    Il faudrait sans doute que tu postes le code de ton entité, car le problème semble quand même être à ce niveau.

  20. #20
    Nouveau Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2013
    Messages
    15
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Octobre 2013
    Messages : 15
    Points : 1
    Points
    1
    Par défaut
    Salut,

    Merci Arnooo pour cette réponse.

    J'ai testé de mettre ORM\Entity avant et après ORM\Table, ca ne change pas l'erreur.
    Il me semble aussi que j'avais déjà testé mon MembreRepository depuis un controller, et l'erreur était là même. Je vais quand même retester cette idée, et tester container:debug comme suggéré.

    Le code de l'entité:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    <?php
    // src/Design/InitializrBundle/Entity/Membre.php
     
    namespace Design\InitializrBundle\Entity;
     
    use Doctrine\ORM\Mapping as ORM;
    use Symfony\Component\Security\Core\User\AdvancedUserInterface;
    use Symfony\Component\Security\Core\User\EquatableInterface;
     
    /**
     * @ORM\Entity(repositoryClass="Design\InitializrBundle\Entity\MembreRepository")
     * @ORM\Table(name="membre")
     */
    class Membre implements AdvancedUserInterface, \Serializable
    {
        /**
         * @var string
         *
         * @ORM\Column(name="mdp_membre", type="string", length=128, nullable=false)
         */
        private $mdpMembre;
     
        /**
         * @var \DateTime
         *
         * @ORM\Column(name="date_naissance", type="date", nullable=false)
         */
        private $dateNaissance;
     
        /**
         * @var string
         *
         * @ORM\Column(name="adresse", type="string", length=128, nullable=false)
         */
        private $adresse;
     
        /**
         * @var boolean
         *
         * @ORM\Column(name="est_valide_membre", type="boolean", nullable=false)
         */
        private $estValideMembre;
     
        /**
         * @var string
         *
         * @ORM\Column(name="salt_membre", type="string", length=128, nullable=false)
         */
        private $saltMembre;
     
        /**
         * @var boolean
         *
         * @ORM\Column(name="active_membre", type="boolean", nullable=true)
         */
        private $activeMembre;
     
        /**
         * @var \Design\InitializrBundle\Entity\Personne
         *
         * @ORM\Id
         * @ORM\GeneratedValue(strategy="NONE")
         * @ORM\OneToOne(targetEntity="Design\InitializrBundle\Entity\Personne")
         * @ORM\JoinColumns({
         *   @ORM\JoinColumn(name="id_personne_membre", referencedColumnName="id_personne")
         * })
         */
        private $idPersonneMembre;
     
    	/**
         * Set mdpMembre
         *
         * @param string $mdpMembre
         * @return Membre
         */
        public function setMdpMembre($mdpMembre)
        {
            $this->mdpMembre = $mdpMembre;
     
            return $this;
        }
     
        /**
         * Get mdpMembre
         *
         * @return string 
         */
        public function getMdpMembre()
        {
            return $this->mdpMembre;
        }
     
        /**
         * Set dateNaissance
         *
         * @param \DateTime $dateNaissance
         * @return Membre
         */
        public function setDateNaissance($dateNaissance)
        {
            $this->dateNaissance = $dateNaissance;
     
            return $this;
        }
     
        /**
         * Get dateNaissance
         *
         * @return \DateTime 
         */
        public function getDateNaissance()
        {
            return $this->dateNaissance;
        }
     
        /**
         * Set adresse
         *
         * @param string $adresse
         * @return Membre
         */
        public function setAdresse($adresse)
        {
            $this->adresse = $adresse;
     
            return $this;
        }
     
        /**
         * Get adresse
         *
         * @return string 
         */
        public function getAdresse()
        {
            return $this->adresse;
        }
     
        /**
         * Set estValideMembre
         *
         * @param boolean $estValideMembre
         * @return Membre
         */
        public function setEstValideMembre($estValideMembre)
        {
            $this->estValideMembre = $estValideMembre;
     
            return $this;
        }
     
        /**
         * Get estValideMembre
         *
         * @return boolean 
         */
        public function getEstValideMembre()
        {
            return $this->estValideMembre;
        }
     
        /**
         * Set saltMembre
         *
         * @param string $saltMembre
         * @return Membre
         */
        public function setSaltMembre($saltMembre)
        {
            $this->saltMembre = $saltMembre;
     
            return $this;
        }
     
        /**
         * Get saltMembre
         *
         * @return string 
         */
        public function getSaltMembre()
        {
            return $this->saltMembre;
        }
     
        /**
         * Set activeMembre
         *
         * @param boolean $activeMembre
         * @return Membre
         */
        public function setActiveMembre($activeMembre)
        {
            $this->activeMembre = $activeMembre;
     
            return $this;
        }
     
        /**
         * Get activeMembre
         *
         * @return boolean 
         */
        public function getActiveMembre()
        {
            return $this->activeMembre;
        }
     
        /**
         * Set idPersonneMembre
         *
         * @param \Design\InitializrBundle\Entity\Personne $idPersonneMembre
         * @return Membre
         */
        public function setIdPersonneMembre(\Design\InitializrBundle\Entity\Personne $idPersonneMembre)
        {
            $this->idPersonneMembre = $idPersonneMembre;
     
            return $this;
        }
     
        /**
         * Get idPersonneMembre
         *
         * @return \Design\InitializrBundle\Entity\Personne 
         */
        public function getIdPersonneMembre()
        {
            return $this->idPersonneMembre;
        }
     
        /**
         * Constructor
         */
        public function __construct()
        {
        	$this->activeMembre = true;
        	$this->estValideMembre = false;
        }
     
        public function isEqualTo(UserInterface $user)
        {
        	return $this->getUsername() === $user->getUsername();
        }
     
        public function toString()
        {
        	return "[Membre]:"."<nom>:".$this->idPersonneMembre->getNom()."<prenom>:".$this->idPersonneMembre->getPrenom()."<username>:".$this->getUsername();
        }
     
        /*****************************/    
        /* methode de user interface */
        /*****************************/
     
        /*
         * username : le mail de la personne liee au membre
         */
        public function getUsername()
        {
        	return $this->idPersonneMembre->getMail();
        }
     
        /*
         * Equivalent de getSaltMembre
         */
        public function getSalt()
        {
        	return $this->saltMembre;
        }
     
        /*
         * Equivalent de getMdpMembre
         */
        public function getPassword()
        {
        	return $this->mdpMembre;
        }
     
        public function getRoles()
        {
        	return array('ROLE_USER');
        }
     
        public function eraseCredentials()
        {
        }
     
        /*****************************/
        /*****************************/
        /*****************************/
     
        /*****************************/
        /*    methode de Advanced    */
        /*****************************/
        public function isAccountNonExpired()
        {
        	return true;
        }
     
        public function isAccountNonLocked()
        {
        	return true;
        }
     
        public function isCredentialsNonExpired()
        {
        	return true;
        }
     
        public function isEnabled()
        {
        	if( !$this->isActive || !$this->estValideMembre )
        		return false;
        	else
        		return true;
        }
     
        /*****************************/
        /*****************************/
        /*****************************/
     
        /*****************************/
        /*   methode de \Serialize   */
        /*****************************/
     
        /*
         * see \Serializable::serialize()
         */
        public function serialize()
        {
        	return serialize(array(
        			$this->idPersonneMembre,
        	));
        }
     
        /*
         * see \Serializable::unserialize()
         */
        public function unserialize($serialized)
        {
        	list (
        			$this->idPersonneMembre,
        	) = unserialize($serialized);
        }
     
        /*****************************/
        /*****************************/
        /*****************************/ 
    }
    Cordialement

Discussions similaires

  1. [RTFEditorKit] Problème d'utilisation
    Par jean.lamy dans le forum Entrée/Sortie
    Réponses: 7
    Dernier message: 21/10/2004, 18h30
  2. Problème d'utilisation de Mysql avec dev-c++
    Par Watchi dans le forum Dev-C++
    Réponses: 10
    Dernier message: 06/08/2004, 14h35
  3. [cvs] problèmes d'utilisation
    Par gromite dans le forum Eclipse Java
    Réponses: 3
    Dernier message: 29/06/2004, 17h41
  4. Problème: Requête utilisant NOT IN
    Par fages dans le forum Langage SQL
    Réponses: 4
    Dernier message: 04/05/2004, 10h18
  5. problème d'utilisation avec turbo pascal 7.0
    Par le 27 dans le forum Turbo Pascal
    Réponses: 4
    Dernier message: 03/12/2003, 10h44

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo