Zend FR

Consultez la FAQ sur le ZF avant de poster une question

Vous n'êtes pas identifié.

#51 12-02-2015 14:54:32

JGreco
Administrateur
Date d'inscription: 22-12-2012
Messages: 432

Re: problème zend_navigation xml

n'oublie pas une chose :

Mon exemple n'est pas complet, par exemple si tu veux que les id suivent un pattern précis tu peux le préciser par :

Code:

[lang=php]
'contact' => array(
                        'type'    => 'Segment',
                        'options' => array(
                            'route'    => '/contact/:id',
                            'constraints' => array(
                                'id' => '[0-9]+', // <- mon paramètre doit être un entier
                            ),
                            'defaults' => array(
                                'controller' => 'Contact\Controller\ContactController',
                                'action'     => 'index',
                            ),
                        ),
                    ),

ZF2 et doctrine addict
profil stack overflow : http://stackoverflow.com/users/3333246/ … ab=profile

Hors ligne

 

#52 12-02-2015 15:02:33

yoann92
Membre
Date d'inscription: 02-07-2012
Messages: 75

Re: problème zend_navigation xml

Merci JGreco,

tu veux dire qu'on fait un espèce de filtre sur l'id comme quoi on attend un int ?

j'ai mis mon code à jour mais même problème, 404.

Code:

[lang=php]

<?php
/**
 *
 */
return array(
    'router' => array(
        'routes' => array(
            'contact' => array(
                'type'    => 'Literal',
                'options' => array(
                    'route'       => '/contact',
                    'defaults' => array(
                        'controller' => 'Contact\Controller\Index',
                        'action'     => 'liste',
                    ),
                ),
                'may_terminate' => true,
                'child_routes' => array(
                    'index' => array(
                        'type'    => 'Segment',
                        'options' => array(
                            'route'    => '/index[/:action][/:id]',
                            'constraints' => array(
                                'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                                'id'     => '[0-9]+',
                            ),
                            'defaults' => array(
                                '__NAMESPACE__' => 'Contact\Controller',
                                'controller' => 'Contact\Controller\Index',
                                'action'     => 'index',
                            ),
                        ),
                        'may_terminate' => true,
                        'child_routes' => array(
                            'add' => array(
                                'type'    => 'Literal',
                                'options' => array(
                                    'route'    => '/add',
                                    'defaults' => array(
                                        'controller' => 'Contact\Controller\Index',
                                        'action' => 'add',
                                    ),
                                ),
                                'edit' => array(
                                    'type' => 'Segment',
                                    'options' => array(
                                        'route' => '/edit[/:id]',
                                        'defaults' => array(
                                            'controller' => 'Contact\Controller\Index',
                                            'action' => 'edit',
                                            'id'     => '[0-9]+',
                                        )
                                    )
                                ),
                                'delete' => array(
                                    'type' => 'Segment',
                                    'options' => array(
                                        'route' => '/delete[/:id]',
                                        'defaults' => array(
                                            'controller' => 'Contact\Controller\Index',
                                            'action' => 'delete',
                                            'id'     => '[0-9]+',
                                        )
                                    )
                                ),
                            ),
                        ),
                    ),
                ),
            ),
        ),
    ),
    'service_manager' => array(
        'abstract_factories' => array(
            'Zend\Cache\Service\StorageCacheAbstractServiceFactory',
            'Zend\Log\LoggerAbstractServiceFactory',
        ),
        'aliases' => array(
            'translator' => 'MvcTranslator',
        ),
        'factories' => array(
            'navigation' => 'Zend\Navigation\Service\DefaultNavigationFactory',
        ),
    ),
    'translator' => array(
        'locale' => 'fr_FR',
        'translation_file_patterns' => array(
            array(
                'type'     => 'gettext',
                'base_dir' => __DIR__ . '/../language',
                'pattern'  => '%s.mo',
            ),
        ),
    ),
    'controllers' => array(
        'invokables' => array(
            'Contact\Controller\Index' => 'Contact\Controller\Index'
        ),
    ),
    'view_manager' => array(
        'display_not_found_reason' => true,
        'display_exceptions'       => true,
        'doctype'                  => 'HTML5',
        'not_found_template'       => 'error/404',
        'exception_template'       => 'error/index',
        'template_map' => array(
            'contact/index/add'                   => __DIR__ . '/../views/contact/index/add.phtml',
            'contact/index/associate'                 => __DIR__ . '/../views/contact/index/associate.phtml',
            'contact/index/associations-list'       => __DIR__ . '/../views/contact/index/associations-list.phtml',
            'contact/index/delete'                     => __DIR__ . '/../views/contact/index/delete.phtml',
            'contact/index/dissociate'                 => __DIR__ . '/../views/contact/index/dissociate.phtml',
            'contact/index/edit'                   => __DIR__ . '/../views/contact/index/edit.phtml',
            'contact/index/index'                   => __DIR__ . '/../views/contact/index/index.phtml',
            'contact/index/list'                   => __DIR__ . '/../views/contact/index/list.phtml',
            'contact/index/sheet'                   => __DIR__ . '/../views/contact/index/sheet.phtml',
        ),
        'template_path_stack' => array(
            __DIR__ . '/../views',
        ),
    ),
    // Placeholder for console routes
    'console' => array(
        'router' => array(
            'routes' => array(
            ),
        ),
    ),
    'navigation' => array(
        'type'    => 'literal',
        'default' => array(
            array(
                'label' => 'Contact',
                'route' => 'contact',
                'pages' => array(
                    array(
                        'label'  => 'Home contact',
                        'route'  => 'contact',
                        'action' => 'index',
                    ),
                    array(
                        'label'  => 'Liste',
                        'route'  => 'contact',
                        'action' => 'list',
                    ),
                    array(
                        'label'  => 'Ajout',
                        'route'  => 'contact',
                        'action' => 'add',
                    ),
                    array(
                        'label'  => 'Modifier',
                        'route'  => 'contact',
                        'action' => 'edit',
                    ),
                    array(
                        'label'  => 'Supprimer',
                        'route'  => 'contact',
                        'action' => 'delete',
                    ),
                    array(
                        'label'  => 'Associer',
                        'route'  => 'contact',
                        'action' => 'associate',
                    ),
                    array(
                        'label'  => 'Désassocier',
                        'route'  => 'contact',
                        'action' => 'dissociate',
                    ),
                    array(
                        'label'  => 'Fiche',
                        'route'  => 'contact',
                        'action' => 'sheet',
                    ),
                    array(
                        'label'  => 'Liste des associations',
                        'route'  => 'contact',
                        'action' => 'link-list',
                    ),
                ),
            ),
        ),
    ),
);

j'ai l'impression de mieux comprendre, mais comme ca fait trois jours que j'y suis je commence à plus y voir clair.
Merci de votre aide.

Hors ligne

 

#53 12-02-2015 15:21:27

flobrflo
Membre
Lieu: Marseille
Date d'inscription: 26-04-2013
Messages: 376

Re: problème zend_navigation xml

Essaye ça pour voir : www.site.fr/contact/index/liste/22
^^

Hors ligne

 

#54 12-02-2015 15:27:48

yoann92
Membre
Date d'inscription: 02-07-2012
Messages: 75

Re: problème zend_navigation xml

merci flobrflo,

pareil je tombe sur une belle 404
Not Found

The requested URL /contact/index/liste/22 was not found on this server.

je pensais avoir bien fait pour une fois

Dernière modification par yoann92 (12-02-2015 15:29:14)

Hors ligne

 

#55 12-02-2015 15:34:13

flobrflo
Membre
Lieu: Marseille
Date d'inscription: 26-04-2013
Messages: 376

Re: problème zend_navigation xml

A tu bien l'action qui correspond à ta route dans ton controleur? ^^

Hors ligne

 

#56 12-02-2015 15:35:36

yoann92
Membre
Date d'inscription: 02-07-2012
Messages: 75

Re: problème zend_navigation xml

oui , mais je pense que j'ai un problème de parentheses la addAction prenait les trois autres.

Je corrige ca, j'arrive


J'ai corrigé mais cela change rien j'ai bien mon action list mais même www.site.fr/contact ne fonctionne pas.

Ca me rend dingue....

Code:

[lang=php]

<?php
/**
 *
 */
return array(
    'router' => array(
        'routes' => array(
            'contact' => array(
                'type'    => 'Literal',
                'options' => array(
                    'route'       => '/contact',
                    'defaults' => array(
                        'controller' => 'Contact\Controller\Index',
                        'action'     => 'list',
                    ),
                ),
                'may_terminate' => true,
                'child_routes' => array(
                    'index' => array(
                        'type'    => 'Segment',
                        'options' => array(
                            'route'    => '/index[/:action][/:id]',
                            'constraints' => array(
                                'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                                'id'     => '[0-9]+',
                            ),
                            'defaults' => array(
                                '__NAMESPACE__' => 'Contact\Controller',
                                'controller' => 'Contact\Controller\Index',
                                'action'     => 'index',
                            ),
                        ),
                        'may_terminate' => true,
                        'child_routes' => array(
                            'add' => array(
                                'type'    => 'Literal',
                                'options' => array(
                                    'route'    => '/add',
                                    'defaults' => array(
                                        'controller' => 'Contact\Controller\Index',
                                        'action' => 'add',
                                    ),
                                ),
                            ),
                            'edit' => array(
                                'type' => 'Segment',
                                'options' => array(
                                    'route' => '/edit[/:id]',
                                    'defaults' => array(
                                        'controller' => 'Contact\Controller\Index',
                                        'action' => 'edit',
                                        'id'     => '[0-9]+',
                                    )
                                )
                            ),
                            'delete' => array(
                                'type' => 'Segment',
                                'options' => array(
                                    'route' => '/delete[/:id]',
                                    'defaults' => array(
                                        'controller' => 'Contact\Controller\Index',
                                        'action' => 'delete',
                                        'id'     => '[0-9]+',
                                    )
                                ),
                            ),
                            'list' => array(
                                'type'    => 'Literal',
                                'options' => array(
                                    'route'    => '/list',
                                    'defaults' => array(
                                        'controller' => 'Contact\Controller\Index',
                                        'action' => 'list',
                                    ),
                                ),
                            ),
                        ),
                    ),
                ),
            ),
        ),
    ),
    'service_manager' => array(
        'abstract_factories' => array(
            'Zend\Cache\Service\StorageCacheAbstractServiceFactory',
            'Zend\Log\LoggerAbstractServiceFactory',
        ),
        'aliases' => array(
            'translator' => 'MvcTranslator',
        ),
        'factories' => array(
            'navigation' => 'Zend\Navigation\Service\DefaultNavigationFactory',
        ),
    ),
    'translator' => array(
        'locale' => 'fr_FR',
        'translation_file_patterns' => array(
            array(
                'type'     => 'gettext',
                'base_dir' => __DIR__ . '/../language',
                'pattern'  => '%s.mo',
            ),
        ),
    ),
    'controllers' => array(
        'invokables' => array(
            'Contact\Controller\Index' => 'Contact\Controller\Index'
        ),
    ),
    'view_manager' => array(
        'display_not_found_reason' => true,
        'display_exceptions'       => true,
        'doctype'                  => 'HTML5',
        'not_found_template'       => 'error/404',
        'exception_template'       => 'error/index',
        'template_map' => array(
            'contact/index/add'                   => __DIR__ . '/../views/contact/index/add.phtml',
            'contact/index/associate'                 => __DIR__ . '/../views/contact/index/associate.phtml',
            'contact/index/associations-list'       => __DIR__ . '/../views/contact/index/associations-list.phtml',
            'contact/index/delete'                     => __DIR__ . '/../views/contact/index/delete.phtml',
            'contact/index/dissociate'                 => __DIR__ . '/../views/contact/index/dissociate.phtml',
            'contact/index/edit'                   => __DIR__ . '/../views/contact/index/edit.phtml',
            'contact/index/index'                   => __DIR__ . '/../views/contact/index/index.phtml',
            'contact/index/list'                   => __DIR__ . '/../views/contact/index/list.phtml',
            'contact/index/sheet'                   => __DIR__ . '/../views/contact/index/sheet.phtml',
        ),
        'template_path_stack' => array(
            __DIR__ . '/../views',
        ),
    ),
    // Placeholder for console routes
    'console' => array(
        'router' => array(
            'routes' => array(
            ),
        ),
    ),
    'navigation' => array(
        'type'    => 'literal',
        'default' => array(
            array(
                'label' => 'Contact',
                'route' => 'contact',
                'pages' => array(
                    array(
                        'label'  => 'Home contact',
                        'route'  => 'contact',
                        'action' => 'index',
                    ),
                    array(
                        'label'  => 'Liste',
                        'route'  => 'contact',
                        'action' => 'list',
                    ),
                    array(
                        'label'  => 'Ajout',
                        'route'  => 'contact',
                        'action' => 'add',
                    ),
                    array(
                        'label'  => 'Modifier',
                        'route'  => 'contact',
                        'action' => 'edit',
                    ),
                    array(
                        'label'  => 'Supprimer',
                        'route'  => 'contact',
                        'action' => 'delete',
                    ),
                    array(
                        'label'  => 'Associer',
                        'route'  => 'contact',
                        'action' => 'associate',
                    ),
                    array(
                        'label'  => 'Désassocier',
                        'route'  => 'contact',
                        'action' => 'dissociate',
                    ),
                    array(
                        'label'  => 'Fiche',
                        'route'  => 'contact',
                        'action' => 'sheet',
                    ),
                    array(
                        'label'  => 'Liste des associations',
                        'route'  => 'contact',
                        'action' => 'link-list',
                    ),
                ),
            ),
        ),
    ),
);

merci d'avance.

Dernière modification par yoann92 (12-02-2015 15:44:26)

Hors ligne

 

#57 12-02-2015 17:51:36

JGreco
Administrateur
Date d'inscription: 22-12-2012
Messages: 432

Re: problème zend_navigation xml

Coté vue comment tu déclare tes routes ? avec le $this->url

De plus si tu fais :

Code:

[lang=php]
'defaults' => array(
                                '__NAMESPACE__' => 'Contact\Controller',
                                'controller' => 'Contact\Controller\Index',
                                'action'     => 'index',
                            ),

transforme ton code en ceci

Code:

[lang=php]
'defaults' => array(
                                '__NAMESPACE__' => 'Contact\Controller',
                                'controller' => 'Index',
                                'action'     => 'index',
                            ),

Car tu déclare deux fois ton namespace et sa sert a rien. Soit tu fait controller avec le FQCN soit tu met la clé __namespace__ mais la clé controller ne possède juste que le nom.


ZF2 et doctrine addict
profil stack overflow : http://stackoverflow.com/users/3333246/ … ab=profile

Hors ligne

 

#58 12-02-2015 17:53:39

flobrflo
Membre
Lieu: Marseille
Date d'inscription: 26-04-2013
Messages: 376

Re: problème zend_navigation xml

Si je peu me permettre, avant de te lancer dans toutes ces routes,
tu devrais voir avec une seule pour être sur de ton indentation :

Code:

[lang=php]
'router' => array(
    'routes' => array(
        'contact' => array(
                'type'    => 'Literal',
                'options' => array(
                    'route'       => '/contact',
                    'defaults' => array(
                        'controller' => 'Contact\Controller\Index',
                        'action'     => 'list',
                    ),
                ),
           ),
     ),
),

Hors ligne

 

#59 12-02-2015 18:03:35

yoann92
Membre
Date d'inscription: 02-07-2012
Messages: 75

Re: problème zend_navigation xml

merci JGreco,

j'ai fait les modifs que tu m'as dit en effet, c'était déclaré 2 fois pour le namespace.
Après les routes j'ai pas trop touché pour l'instant, je faisais que la navigation qui est déclarée dans le fichier de config, tout en bas. Du coup j'ai une clé nagvigation dans la config du module application, plus celle dans le module contact, je l'ai découpé comme tu me l'as stipulé tout a l'heure vu que ca les merge après.

mon config contact :

Code:

[lang=php]
<?php
/**
 *
 */
return array(
    'router' => array(
        'routes' => array(
            'contact' => array(
                'type'    => 'Literal',
                'options' => array(
                    'route'       => '/contact',
                    'defaults' => array(
                        '__NAMESPACE__' => 'Contact\Controller',
                        'controller' => 'Index',
                        'action'     => 'list',
                    ),
                ),
                'may_terminate' => true,
                'child_routes' => array(
                    'index' => array(
                        'type'    => 'Segment',
                        'options' => array(
                            'route'    => '/index[/:action][/:id]',
                            'constraints' => array(
                                'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                                'id'     => '[0-9]+',
                            ),
                            'defaults' => array(
                                'controller' => 'Index',
                                'action'     => 'index',
                            ),
                        ),
                        'may_terminate' => true,
                        'child_routes' => array(
                            'add' => array(
                                'type'    => 'Literal',
                                'options' => array(
                                    'route'    => '/add',
                                    'defaults' => array(
                                        'controller' => 'Index',
                                        'action' => 'add',
                                    ),
                                ),
                            ),
                            'edit' => array(
                                'type' => 'Segment',
                                'options' => array(
                                    'route' => '/edit[/:id]',
                                    'defaults' => array(
                                        'controller' => 'Index',
                                        'action' => 'edit',
                                        'id'     => '[0-9]+',
                                    )
                                )
                            ),
                            'delete' => array(
                                'type' => 'Segment',
                                'options' => array(
                                    'route' => '/delete[/:id]',
                                    'defaults' => array(
                                        'controller' => 'Index',
                                        'action' => 'delete',
                                        'id'     => '[0-9]+',
                                    )
                                ),
                            ),
                            'list' => array(
                                'type'    => 'Literal',
                                'options' => array(
                                    'route'    => '/list',
                                    'defaults' => array(
                                        'controller' => 'Contact\Controller\Index',
                                        'action' => 'list',
                                    ),
                                ),
                            ),
                        ),
                    ),
                ),
            ),
        ),
    ),
    'service_manager' => array(
        'abstract_factories' => array(
            'Zend\Cache\Service\StorageCacheAbstractServiceFactory',
            'Zend\Log\LoggerAbstractServiceFactory',
        ),
        'aliases' => array(
            'translator' => 'MvcTranslator',
        ),
        'factories' => array(
            'navigation' => 'Zend\Navigation\Service\DefaultNavigationFactory',
        ),
    ),
    'translator' => array(
        'locale' => 'fr_FR',
        'translation_file_patterns' => array(
            array(
                'type'     => 'gettext',
                'base_dir' => __DIR__ . '/../language',
                'pattern'  => '%s.mo',
            ),
        ),
    ),
    'controllers' => array(
        'invokables' => array(
            'Contact\Controller\Index' => 'Contact\Controller\Index'
        ),
    ),
    'view_manager' => array(
        'display_not_found_reason' => true,
        'display_exceptions'       => true,
        'doctype'                  => 'HTML5',
        'not_found_template'       => 'error/404',
        'exception_template'       => 'error/index',
        'template_map' => array(
            'contact/index/add'                   => __DIR__ . '/../views/contact/index/add.phtml',
            'contact/index/associate'                 => __DIR__ . '/../views/contact/index/associate.phtml',
            'contact/index/associations-list'       => __DIR__ . '/../views/contact/index/associations-list.phtml',
            'contact/index/delete'                     => __DIR__ . '/../views/contact/index/delete.phtml',
            'contact/index/dissociate'                 => __DIR__ . '/../views/contact/index/dissociate.phtml',
            'contact/index/edit'                   => __DIR__ . '/../views/contact/index/edit.phtml',
            'contact/index/index'                   => __DIR__ . '/../views/contact/index/index.phtml',
            'contact/index/list'                   => __DIR__ . '/../views/contact/index/list.phtml',
            'contact/index/sheet'                   => __DIR__ . '/../views/contact/index/sheet.phtml',
        ),
        'template_path_stack' => array(
            __DIR__ . '/../views',
        ),
    ),
    // Placeholder for console routes
    'console' => array(
        'router' => array(
            'routes' => array(
            ),
        ),
    ),
    'navigation' => array(
        'type'    => 'literal',
        'default' => array(
            array(
                'label' => 'Contact',
                'route' => 'contact',
                'pages' => array(
                    array(
                        'label'  => 'Home contact',
                        'route'  => 'contact',
                        'action' => 'index',
                    ),
                    array(
                        'label'  => 'Liste',
                        'route'  => 'contact',
                        'action' => 'list',
                    ),
                    array(
                        'label'  => 'Ajout',
                        'route'  => 'contact',
                        'action' => 'add',
                    ),
                    array(
                        'label'  => 'Modifier',
                        'route'  => 'contact',
                        'action' => 'edit',
                    ),
                    array(
                        'label'  => 'Supprimer',
                        'route'  => 'contact',
                        'action' => 'delete',
                    ),
                    array(
                        'label'  => 'Associer',
                        'route'  => 'contact',
                        'action' => 'associate',
                    ),
                    array(
                        'label'  => 'Désassocier',
                        'route'  => 'contact',
                        'action' => 'dissociate',
                    ),
                    array(
                        'label'  => 'Fiche',
                        'route'  => 'contact',
                        'action' => 'sheet',
                    ),
                    array(
                        'label'  => 'Liste des associations',
                        'route'  => 'contact',
                        'action' => 'link-list',
                    ),
                ),
            ),
        ),
    ),
);

et mon layout qui se trouve dans le module application.

Code:

[lang=php]
<?php /* @var $this Zend\View\Renderer\PhpRenderer */ ?>
<?php echo $this->doctype( ); ?>
<html lang="fr" >
<head>
    <title>WebMRL</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="robots" content="index, follow" />
    <meta name="keywords" content="WebMRL, netasq, integration, AIS, Obiane, OBS" />
    <meta name="description" content="WebMRL, netasq, integration, AIS, Obiane, OBS" />
    <meta name="page-topic" content="WebMRL, netasq, integration, AIS, Obiane, OBS" />
    <meta name="revisit-after" content="14 days">
    <meta name="company" content="AIS">
    <meta name="author" content="AIS">
    <?php
    echo $this->headLink()
        ->prependStylesheet('/css/obs.css');
    ?>



</head>

<body id="navhnobitmap" class="tundra">
<div id="contener">
    <div id="header">
        <div id="logo" style="margin-top: -20px;">
            <a href="http://www.orange-business.com/">
                <img src="/images/Logo-OBS_40pix-Web.gif" alt="orange business services" height="80" width="137" border="0" /></a>
        </div>
        <div style="float: right;">
            <img src="/images/puce_simple.gif">&nbsp;&nbsp;<a href="http://www.orange-business.com/" target="_blank">orange-business.com</a><br>
        </div>
        <div class="spacer">
        </div>
        <div id="barreintro">
            <div id="intro">Bienvenue sur le site d'intégration "Mon Réseau Local" de Advanced Integration Services d'Orange Business Services</div>
            <div id="logout"></div>
        </div>
        <div id="nav">
            <ul>
            <?php
                echo $this->navigation('navigation')
                        ->menu()
                        ->setMinDepth(0)
                        ->setMaxDepth(0)
                        ->setUlClass('nav');
            ?>
                </ul>
            <div id="subnav">
            <?php
                echo $this->navigation('navigation')
                        ->menu()
                        ->renderMenu(null, array(
                            'minDepth' => 1,
                            'maxDepth' => 1,
                            'onlyActiveBranch' => true,
                            'renderParents' => false
                            )
                        );
            ?>
            </div>
        </div>
    </div>
    <div class="spacer">
    </div>
    <div id="center">
        <?php echo $this->content; ?>
    </div>
    <br /><br />
    <div id="footer">
        <div class="barre">
        </div>
        <div id="selectfooter1">
        </div>
        <div id="footerleft">
            <ul><li><a href="tools/legal/index.html">mentions légales</a></li></ul>
        </div>
        <div id="selectfooter4">
            <font class="signature">
                <a href="http://www.orange.com/" target="_blank"><img src="/images/esperluette-20.gif" alt="FT Group" width="30" height="30" title="FT Group" border="0" /></a>
            </font>
        </div>
    </div>
</div>
</body>
</html>

merci d'avance.
La pour l'instant j'arrive pas à aller sur l'url www.site.fr/contact/index/list

Hors ligne

 

#60 12-02-2015 18:05:01

yoann92
Membre
Date d'inscription: 02-07-2012
Messages: 75

Re: problème zend_navigation xml

je vais tester flobrflo. je te dis ca tout de suite

J'ai fait ce que tu m'as dit pour y voir plus clair en effet, mais j'ai le même résultat.
ps: et bien sur tu peux te permettre :-)

Dernière modification par yoann92 (12-02-2015 18:07:57)

Hors ligne

 

#61 12-02-2015 18:14:18

flobrflo
Membre
Lieu: Marseille
Date d'inscription: 26-04-2013
Messages: 376

Re: problème zend_navigation xml

Tu a testé avec la seul route :
www.monsite.com/contact

avec dans ton controleur la route listAction() ?

Alors question con, comment s'appel ton controlleur dans ta structure? Index ou IndexController?
(IndexController serait plus clair ^^)

Hors ligne

 

#62 12-02-2015 18:25:10

yoann92
Membre
Date d'inscription: 02-07-2012
Messages: 75

Re: problème zend_navigation xml

oui l'action est présente voici mon controller :

Code:

[lang=php]
<?php

/* Déclaration des l'espace dee nom. */
namespace Contact\Controller;

/* Réalisation des imports et des aliases. */
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

/**
 * Contrôleur 'Index'
 */
class Index  extends AbstractActionController {

    /**
     * (non-PHPdoc)
     * @see \Zend\Mvc\Controller\AbstractActionController::indexAction()
     */
    public function indexAction( ) {

        /* Création du ViewModel. */
        $oVModel = new ViewModel;

        /* Assignation des variables. */
        $oVModel
            ->setVariable( 'message', 'contact');
        echo 'fsddghdh';            //->setTemplate( 'application/index/index-bis');

        /* Retour du ViewModel. */
        return $oVModel;
    }

    public function addAction() {
        /* Création du ViewModel. */
        $oVModel = new ViewModel;

        /* Assignation des variables. */
        $oVModel
            ->setVariable( 'message', 'contact');


        /* Retour du ViewModel. */
        return $oVModel;
    }

    public function associateAction() {
        /* Création du ViewModel. */
        $oVModel = new ViewModel;

        /* Assignation des variables. */
        $oVModel
            ->setVariable( 'message', 'contact');


        /* Retour du ViewModel. */
        return $oVModel;
    }

    public function associationsListAction() {
        /* Création du ViewModel. */
        $oVModel = new ViewModel;

        /* Assignation des variables. */
        $oVModel
            ->setVariable( 'message', 'contact');


        /* Retour du ViewModel. */
        return $oVModel;
    }

    public function DeleteAction() {
        /* Création du ViewModel. */
        $oVModel = new ViewModel;

        /* Assignation des variables. */
        $oVModel
            ->setVariable( 'message', 'contact');


        /* Retour du ViewModel. */
        return $oVModel;
    }

    public function dissociateAction() {
        /* Création du ViewModel. */
        $oVModel = new ViewModel;

        /* Assignation des variables. */
        $oVModel
            ->setVariable( 'message', 'contact');


        /* Retour du ViewModel. */
        return $oVModel;
    }

    public function editAction() {
        /* Création du ViewModel. */
        $oVModel = new ViewModel;

        /* Assignation des variables. */
        $oVModel
            ->setVariable( 'message', 'contact');


        /* Retour du ViewModel. */
        return $oVModel;
    }

    public function listAction() {
        /* Création du ViewModel. */
        $oVModel = new ViewModel;

        /* Assignation des variables. */
        $oVModel
            ->setVariable( 'message', 'contact');


        /* Retour du ViewModel. */
        return $oVModel;
    }

    public function sheetAction() {
        /* Création du ViewModel. */
        $oVModel = new ViewModel;

        /* Assignation des variables. */
        $oVModel
            ->setVariable( 'message', 'contact');


        /* Retour du ViewModel. */
        return $oVModel;
    }

}

et son nom c'est Index, c'est pas une question con , on sait jamais.

Hors ligne

 

#63 12-02-2015 18:29:22

flobrflo
Membre
Lieu: Marseille
Date d'inscription: 26-04-2013
Messages: 376

Re: problème zend_navigation xml

Ok donc ça va te faire un petit changement,
mais ta classe "Index" tu va la remplacer par "IndexController" (EDIT : ou contactController serait même plus pertinent)
(S'il te plait ^^)
n'oublie pas de le faire dans le routing , invokable etc...

ensuite, a tu bien un template list.phtml?

Dernière modification par flobrflo (12-02-2015 18:30:08)

Hors ligne

 

#64 12-02-2015 18:39:15

yoann92
Membre
Date d'inscription: 02-07-2012
Messages: 75

Re: problème zend_navigation xml

alors j'ai fait mes modifs j'ai changé le nom en IndexController.php

du coup le controller :

Code:

[lang=php]
class IndexController  extends AbstractActionController

ensuite dans mon répertoire config du module contact j'ai modifié mon autoloaders.php

Code:

[lang=php]
<?php

return [
    'Zend\Loader\ClassMapAutoloader' => [
        [
            'Contract\Controller\Index' => "{$sPath}/controllers/IndexController.php",
        ]
    ],
];

mon config.module.php

Code:

[lang=php]
<?php
/**
 *
 */
return array(
    'router' => array(
        'routes' => array(
            'contact' => array(
                'type'    => 'Literal',
                'options' => array(
                    'route'       => '/contact',
                    'defaults' => array(
                        '__NAMESPACE__' => 'Contact\Controller',
                        'controller' => 'IndexController',
                        'action'     => 'list',
                    ),
                ),
                'may_terminate' => true,
                'child_routes' => array(
                    'index' => array(
                        'type'    => 'Segment',
                        'options' => array(
                            'route'    => '/index[/:action][/:id]',
                            'constraints' => array(
                                'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                                'id'     => '[0-9]+',
                            ),
                            'defaults' => array(
                                'controller' => 'IndexController',
                                'action'     => 'index',
                            ),
                        ),
                        'may_terminate' => true,
                        'child_routes' => array(
                            'add' => array(
                                'type'    => 'Literal',
                                'options' => array(
                                    'route'    => '/add',
                                    'defaults' => array(
                                        'controller' => 'IndexController',
                                        'action' => 'add',
                                    ),
                                ),
                            ),
                            'edit' => array(
                                'type' => 'Segment',
                                'options' => array(
                                    'route' => '/edit[/:id]',
                                    'defaults' => array(
                                        'controller' => 'IndexController',
                                        'action' => 'edit',
                                        'id'     => '[0-9]+',
                                    )
                                )
                            ),
                            'delete' => array(
                                'type' => 'Segment',
                                'options' => array(
                                    'route' => '/delete[/:id]',
                                    'defaults' => array(
                                        'controller' => 'IndexController',
                                        'action' => 'delete',
                                        'id'     => '[0-9]+',
                                    )
                                ),
                            ),
                            'list' => array(
                                'type'    => 'Literal',
                                'options' => array(
                                    'route'    => '/list',
                                    'defaults' => array(
                                        'controller' => 'IndexController',
                                        'action' => 'list',
                                    ),
                                ),
                            ),
                        ),
                    ),
                ),
            ),
        ),
    ),
    'service_manager' => array(
        'abstract_factories' => array(
            'Zend\Cache\Service\StorageCacheAbstractServiceFactory',
            'Zend\Log\LoggerAbstractServiceFactory',
        ),
        'aliases' => array(
            'translator' => 'MvcTranslator',
        ),
        'factories' => array(
            'navigation' => 'Zend\Navigation\Service\DefaultNavigationFactory',
        ),
    ),
    'translator' => array(
        'locale' => 'fr_FR',
        'translation_file_patterns' => array(
            array(
                'type'     => 'gettext',
                'base_dir' => __DIR__ . '/../language',
                'pattern'  => '%s.mo',
            ),
        ),
    ),
    'controllers' => array(
        'invokables' => array(
            'Contact\Controller\IndexController' => 'Contact\Controller\IndexController'
        ),
    ),
    'view_manager' => array(
        'display_not_found_reason' => true,
        'display_exceptions'       => true,
        'doctype'                  => 'HTML5',
        'not_found_template'       => 'error/404',
        'exception_template'       => 'error/index',
        'template_map' => array(
            'contact/index/add'                   => __DIR__ . '/../views/contact/index/add.phtml',
            'contact/index/associate'                 => __DIR__ . '/../views/contact/index/associate.phtml',
            'contact/index/associations-list'       => __DIR__ . '/../views/contact/index/associations-list.phtml',
            'contact/index/delete'                     => __DIR__ . '/../views/contact/index/delete.phtml',
            'contact/index/dissociate'                 => __DIR__ . '/../views/contact/index/dissociate.phtml',
            'contact/index/edit'                   => __DIR__ . '/../views/contact/index/edit.phtml',
            'contact/index/index'                   => __DIR__ . '/../views/contact/index/index.phtml',
            'contact/index/list'                   => __DIR__ . '/../views/contact/index/list.phtml',
            'contact/index/sheet'                   => __DIR__ . '/../views/contact/index/sheet.phtml',
        ),
        'template_path_stack' => array(
            __DIR__ . '/../views',
        ),
    ),
    'navigation' => array(
        'type'    => 'literal',
        'default' => array(
            array(
                'label' => 'Contact',
                'route' => 'contact',
                'pages' => array(
                    array(
                        'label'  => 'Home contact',
                        'route'  => 'contact',
                        'action' => 'index',
                    ),
                    array(
                        'label'  => 'Liste',
                        'route'  => 'contact',
                        'action' => 'list',
                    ),
                    array(
                        'label'  => 'Ajout',
                        'route'  => 'contact',
                        'action' => 'add',
                    ),
                    array(
                        'label'  => 'Modifier',
                        'route'  => 'contact',
                        'action' => 'edit',
                    ),
                    array(
                        'label'  => 'Supprimer',
                        'route'  => 'contact',
                        'action' => 'delete',
                    ),
                    array(
                        'label'  => 'Associer',
                        'route'  => 'contact',
                        'action' => 'associate',
                    ),
                    array(
                        'label'  => 'Désassocier',
                        'route'  => 'contact',
                        'action' => 'dissociate',
                    ),
                    array(
                        'label'  => 'Fiche',
                        'route'  => 'contact',
                        'action' => 'sheet',
                    ),
                    array(
                        'label'  => 'Liste des associations',
                        'route'  => 'contact',
                        'action' => 'link-list',
                    ),
                ),
            ),
        ),
    ),
);

j'ai bien mon template list.phtml

Hors ligne

 

#65 12-02-2015 18:50:43

yoann92
Membre
Date d'inscription: 02-07-2012
Messages: 75

Re: problème zend_navigation xml

je dois y aller j'essaie de revenir tout à l'heure.(21h) sinon au pire demain matin 9h.
Bonne soirée au cas ou et merci encore pour tout.

Hors ligne

 

#66 13-02-2015 08:56:43

flobrflo
Membre
Lieu: Marseille
Date d'inscription: 26-04-2013
Messages: 376

Re: problème zend_navigation xml

Ok,
J'ai relus un peu tous les messages depuis le début du post.

ta config est-elle toujours comme ceci :

Code:

[lang=php]
/* Modules à charger. */
    'modules' => [
         'Application',
        //'Contact',
        /*'Contract',
        'Customer',
        ...

Hors ligne

 

#67 13-02-2015 09:14:11

yoann92
Membre
Date d'inscription: 02-07-2012
Messages: 75

Re: problème zend_navigation xml

Bonjour flobrflo,


oui toujours , je mets mon fichier de config du site.

Code:

[lang=php]
<?php

return [

    /* Configuration des Listerners du ModuleManager. */
    'module_listener_options' => [
        'module_paths' => [
            PATH_ROOT.'/modules',
        ],
    ],

    /* Modules à charger. */
    'modules' => [
         'Application',
        'Contact'
        /*'Contract',
        'Customer',
        'Dashboard',
        'Device',
        'Excel',
        'Login',
        'Tickets',
        'Validation',*/
    ],

    'service_manager' => [
        'factories' => [
            'Db' => 'Zend\Db\Adapter\AdapterServiceFactory',
        ]
    ],
    'db' => [
        'driver'   => 'PDO Mysql',
        'host'     => 'localhost',
        'dbname'   => 'webmrl',
        'username' => 'root',
        'password' => ''
    ],
];

et dans mon autloaders.php du module j'ai corrigé Contract en Contact, mais cela change rien.

Code:

[lang=php]

return [
    'Zend\Loader\ClassMapAutoloader' => [
        [
            'Contact\Controller\IndexController' => "{$sPath}/controllers/IndexController.php",
        ]
    ],
];

et je fais un var_dump dans la méthode getConfig() de ma classe Module de mon module contact il me renvoi bien quelque chose

Code:

[lang=php]
var_dump(require "{$sPath}/config/module.php");


array (size=6)
  'router' => 
    array (size=1)
      'routes' => 
        array (size=1)
          'contact' => 
            array (size=4)
              ...
  'service_manager' => 
    array (size=3)
      'abstract_factories' => 
        array (size=2)
          0 => string 'Zend\Cache\Service\StorageCacheAbstractServiceFactory' (length=53)
          1 => string 'Zend\Log\LoggerAbstractServiceFactory' (length=37)
      'aliases' => 
        array (size=1)
          'translator' => string 'MvcTranslator' (length=13)
      'factories' => 
        array (size=1)
          'navigation' => string 'Zend\Navigation\Service\DefaultNavigationFactory' (length=48)
  'translator' => 
    array (size=2)
      'locale' => string 'fr_FR' (length=5)
      'translation_file_patterns' => 
        array (size=1)
          0 => 
            array (size=3)
              ...
  'controllers' => 
    array (size=1)
      'invokables' => 
        array (size=1)
          'Contact\Controller\IndexController' => string 'Contact\Controller\IndexController' (length=34)
  'view_manager' => 
    array (size=7)
      'display_not_found_reason' => boolean true
      'display_exceptions' => boolean true
      'doctype' => string 'HTML5' (length=5)
      'not_found_template' => string 'error/404' (length=9)
      'exception_template' => string 'error/index' (length=11)
      'template_map' => 
        array (size=9)
          'contact/index/add' => string 'C:\wamp\www\formation\modules\Contact\config/../views/contact/index/add.phtml' (length=77)
          'contact/index/associate' => string 'C:\wamp\www\formation\modules\Contact\config/../views/contact/index/associate.phtml' (length=83)
          'contact/index/associations-list' => string 'C:\wamp\www\formation\modules\Contact\config/../views/contact/index/associations-list.phtml' (length=91)
          'contact/index/delete' => string 'C:\wamp\www\formation\modules\Contact\config/../views/contact/index/delete.phtml' (length=80)
          'contact/index/dissociate' => string 'C:\wamp\www\formation\modules\Contact\config/../views/contact/index/dissociate.phtml' (length=84)
          'contact/index/edit' => string 'C:\wamp\www\formation\modules\Contact\config/../views/contact/index/edit.phtml' (length=78)
          'contact/index/index' => string 'C:\wamp\www\formation\modules\Contact\config/../views/contact/index/index.phtml' (length=79)
          'contact/index/list' => string 'C:\wamp\www\formation\modules\Contact\config/../views/contact/index/list.phtml' (length=78)
          'contact/index/sheet' => string 'C:\wamp\www\formation\modules\Contact\config/../views/contact/index/sheet.phtml' (length=79)
      'template_path_stack' => 
        array (size=1)
          0 => string 'C:\wamp\www\formation\modules\Contact\config/../views' (length=53)
  'navigation' => 
    array (size=2)
      'type' => string 'literal' (length=7)
      'default' => 
        array (size=1)
          0 => 
            array (size=3)
              ...

Dernière modification par yoann92 (13-02-2015 09:19:52)

Hors ligne

 

#68 13-02-2015 09:54:22

flobrflo
Membre
Lieu: Marseille
Date d'inscription: 26-04-2013
Messages: 376

Re: problème zend_navigation xml

Mmmhhhh. bon dernière remarque, après je sèche.. xD

dans ta fonction listAction() mets uniquement un

Code:

[lang=php]
public function listAction() {
die('z-f.Fr');
}

Et enfin, si tu à un résultat positif, je dirais que ton template map est un peu confus, il te permet de surcharger les paths de tes templates (tu devrais pouvoir t'en passer si tu suis l'architecture zf2 ou en redéfinissant le template_patch_stack :

Code:

[lang=php]
'view_manager' => array(
         'template_path_stack' => array(
             'album' => __DIR__ . '/../view',
         ),
     ),

du coup tu n'est pas censé avoir besoin de mettre tout ton chemin (surtout avec le '/config/../views')

Hors ligne

 

#69 13-02-2015 10:08:09

yoann92
Membre
Date d'inscription: 02-07-2012
Messages: 75

Re: problème zend_navigation xml

merci flobrflo,

non cela ne donne rien.

en fait ce que je comprends pas c'est que déjà je ne peux même pas aller sur www.site.fr/contact

Hors ligne

 

#70 13-02-2015 10:13:34

yoann92
Membre
Date d'inscription: 02-07-2012
Messages: 75

Re: problème zend_navigation xml

mais je pense qu'il doit y avoir un problème dans la config, car j'ai juste voulu tester un truc même si je sais que c'est pas bon.


Code:

[lang=php]
'contact' => array(
                'type'    => 'segment',
                'options' => array(
                    'route'       => '/',
                    'defaults' => array(
                        '__NAMESPACE__' => 'Contact\Controller',
                        'controller' => 'IndexController',
                        'action'     => 'list',
                    ),
                ),

au lieu de

Code:

[lang=php]

'contact' => array(
                'type'    => 'Literal',
                'options' => array(
                    'route'       => '/contact',
                    'defaults' => array(
                        '__NAMESPACE__' => 'Contact\Controller',
                        'controller' => 'IndexController',
                        'action'     => 'list',
                    ),
                ),

forcément j'arrive sur www.site.fr et en plus il me charge mon template 404.phtml
mais j'ai ma navigation qui s'affiche (et qui fonctionne pas bien certes).
Mais cela veut dire qu'il est bien chargé

Dernière modification par yoann92 (13-02-2015 10:14:38)

Hors ligne

 

#71 13-02-2015 10:14:09

flobrflo
Membre
Lieu: Marseille
Date d'inscription: 26-04-2013
Messages: 376

Re: problème zend_navigation xml

bon bah la...

vérifie bien le paramétrage de ton module, les autoload etc... refait le getting started point par point pour vérifier que ton module est construit correctement.
Parce qu'a part ça je vois pas X)

Hors ligne

 

#72 13-02-2015 10:15:26

yoann92
Membre
Date d'inscription: 02-07-2012
Messages: 75

Re: problème zend_navigation xml

oui cela peut être que de la config de toute façon, merci encore flobrflo.
Je vais regarder ce qu'il ne va pas.

Hors ligne

 

#73 13-02-2015 10:30:32

JGreco
Administrateur
Date d'inscription: 22-12-2012
Messages: 432

Re: problème zend_navigation xml

Quel est ton arborescence ? Celle standard de ZF2 ou tu l'a personalisé un peu ?

Car ici :

Code:

[lang=php]


return [
    'Zend\Loader\ClassMapAutoloader' => [
        [
            'Contact\Controller\IndexController' => "{$sPath}/controllers/IndexController.php",
        ]
    ],
];

tu as 'controllers' qui ne correspond pas a grand chose pour zf2... Je suis perdu.


ZF2 et doctrine addict
profil stack overflow : http://stackoverflow.com/users/3333246/ … ab=profile

Hors ligne

 

#74 13-02-2015 10:41:11

yoann92
Membre
Date d'inscription: 02-07-2012
Messages: 75

Re: problème zend_navigation xml

bonjour JGreco,

en fait mon archi par module j'ai le repértoire config
ou j'ai autoloaders.php et module.php

dans mon autoloader.php j'ai

Code:

[lang=php]
return [
    'Zend\Loader\ClassMapAutoloader' => [
        [
            'Contact\Controller\Index' => "{$sPath}/controllers/IndexController.php",
        ]
    ],
];

mon module.php

Code:

[lang=php]
<?php
/**
 *
 */
return array(
    'router' => array(
        'routes' => array(
            'contact' => array(
                'type'    => 'Literal',
                'options' => array(
                    'route'       => '/contact',
                    'defaults' => array(
                        '__NAMESPACE__' => 'Contact\Controller',
                        'controller' => 'IndexController',
                        'action'     => 'list',
                    ),
                ),
                'may_terminate' => true,
                'child_routes' => array(
                    'index' => array(
                        'type'    => 'Segment',
                        'options' => array(
                            'route'    => '/index[/:action][/:id]',
                            'constraints' => array(
                                'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                                'id'     => '[0-9]+',
                            ),
                            'defaults' => array(
                                'controller' => 'IndexController',
                                'action'     => 'index',
                            ),
                        ),
                        'may_terminate' => true,
                        'child_routes' => array(
                            'add' => array(
                                'type'    => 'Literal',
                                'options' => array(
                                    'route'    => '/add',
                                    'defaults' => array(
                                        'controller' => 'IndexController',
                                        'action' => 'add',
                                    ),
                                ),
                            ),
                            'edit' => array(
                                'type' => 'Segment',
                                'options' => array(
                                    'route' => '/edit[/:id]',
                                    'defaults' => array(
                                        'controller' => 'IndexController',
                                        'action' => 'edit',
                                        'id'     => '[0-9]+',
                                    )
                                )
                            ),
                            'delete' => array(
                                'type' => 'Segment',
                                'options' => array(
                                    'route' => '/delete[/:id]',
                                    'defaults' => array(
                                        'controller' => 'IndexController',
                                        'action' => 'delete',
                                        'id'     => '[0-9]+',
                                    )
                                ),
                            ),
                            'list' => array(
                                'type'    => 'Literal',
                                'options' => array(
                                    'route'    => '/list',
                                    'defaults' => array(
                                        'controller' => 'IndexController',
                                        'action' => 'list',
                                    ),
                                ),
                            ),
                        ),
                    ),
                ),
            ),
        ),
    ),
    'service_manager' => array(
        'abstract_factories' => array(
            'Zend\Cache\Service\StorageCacheAbstractServiceFactory',
            'Zend\Log\LoggerAbstractServiceFactory',
        ),
        'aliases' => array(
            'translator' => 'MvcTranslator',
        ),
        'factories' => array(
            'navigation' => 'Zend\Navigation\Service\DefaultNavigationFactory',
        ),
    ),
    'translator' => array(
        'locale' => 'fr_FR',
        'translation_file_patterns' => array(
            array(
                'type'     => 'gettext',
                'base_dir' => __DIR__ . '/../language',
                'pattern'  => '%s.mo',
            ),
        ),
    ),
    'controllers' => array(
        'invokables' => array(
            'Contact\Controller\IndexController' => 'Contact\Controller\IndexController'
        ),
    ),
    'view_manager' => array(
        'display_not_found_reason' => true,
        'display_exceptions'       => true,
        'doctype'                  => 'HTML5',
        'not_found_template'       => 'error/404',
        'exception_template'       => 'error/index',
        /*'template_map' => array(
            'contact/index/add'                   => __DIR__ . '/../views/contact/index/add.phtml',
            'contact/index/associate'                 => __DIR__ . '/../views/contact/index/associate.phtml',
            'contact/index/associations-list'       => __DIR__ . '/../views/contact/index/associations-list.phtml',
            'contact/index/delete'                     => __DIR__ . '/../views/contact/index/delete.phtml',
            'contact/index/dissociate'                 => __DIR__ . '/../views/contact/index/dissociate.phtml',
            'contact/index/edit'                   => __DIR__ . '/../views/contact/index/edit.phtml',
            'contact/index/index'                   => __DIR__ . '/../views/contact/index/index.phtml',
            'contact/index/list'                   => __DIR__ . '/../views/contact/index/list.phtml',
            'contact/index/sheet'                   => __DIR__ . '/../views/contact/index/sheet.phtml',
        ),*/
        'template_path_stack' => array(
            __DIR__ . '/../views/contact/index',
        ),
    ),
    'navigation' => array(
        'type'    => 'literal',
        'default' => array(
            array(
                'label' => 'Contact',
                'route' => 'contact',
                'pages' => array(
                    array(
                        'label'  => 'Home contact',
                        'route'  => 'contact',
                        'action' => 'index',
                    ),
                    array(
                        'label'  => 'Liste',
                        'route'  => 'contact',
                        'action' => 'list',
                    ),
                    array(
                        'label'  => 'Ajout',
                        'route'  => 'contact',
                        'action' => 'add',
                    ),
                    array(
                        'label'  => 'Modifier',
                        'route'  => 'contact',
                        'action' => 'edit',
                    ),
                    array(
                        'label'  => 'Supprimer',
                        'route'  => 'contact',
                        'action' => 'delete',
                    ),
                    array(
                        'label'  => 'Associer',
                        'route'  => 'contact',
                        'action' => 'associate',
                    ),
                    array(
                        'label'  => 'Désassocier',
                        'route'  => 'contact',
                        'action' => 'dissociate',
                    ),
                    array(
                        'label'  => 'Fiche',
                        'route'  => 'contact',
                        'action' => 'sheet',
                    ),
                    array(
                        'label'  => 'Liste des associations',
                        'route'  => 'contact',
                        'action' => 'link-list',
                    ),
                ),
            ),
        ),
    ),
);

et ma classe Module => Module.php situé à la racine du module

Code:

[lang=php]
<?php

/* Déclaration de l'espace de nom du Module. */
namespace Contact;

/**
 * Module application
 *
 * @author    Alter Way <formation@alterway.fr>
 * @version    0.9.0
 */
class Module {

    /**
     * Retourne la configuration du site portée par ce Module.
     *
     * @return    array
     */
    public function getConfig( ) {

        /* Récupération du chemin de base du Module. */
        $sPath = __DIR__;

        /* Retour de la configuration. */
        /*echo "<pre>";
        var_dump(require "{$sPath}/config/module.php");
        echo "</pre>";*/
        return require "{$sPath}/config/module.php";
    }

    public function getAutoloaderConfig( ) {

        /* Récupération du chemin de base du Module. */
        $sPath = __DIR__;

        /* Retour de la configuration. */
        return require "{$sPath}/config/autoloaders.php";
    }

    public function getServiceConfig()
    {
        /*return array(
            'factories' => array(
                'Album\Model\AlbumTable' =>  function($sm) {
                    $tableGateway = $sm->get('AlbumTableGateway');
                    $table = new AlbumTable($tableGateway);
                    return $table;
                },
                'AlbumTableGateway' => function ($sm) {
                    $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                    $resultSetPrototype = new ResultSet();
                    $resultSetPrototype->setArrayObjectPrototype(new Album());
                    return new TableGateway('album', $dbAdapter, null, $resultSetPrototype);
                },
            ),
        );*/
    }
}

Hors ligne

 

#75 13-02-2015 10:43:46

yoann92
Membre
Date d'inscription: 02-07-2012
Messages: 75

Re: problème zend_navigation xml

après comme config général à la racine de mon projet j'ai mon autoloaders.php

Code:

[lang=php]
<?php

/* Inclusion de la Fabrique. */
require 'Zend/Loader/AutoloaderFactory.php';

/* Déclaration des aliases et des imports. */
use Zend\Loader\AutoloaderFactory as Factory;
use Zend\Loader\StandardAutoloader as PsrLoader;

/* Mise en place du chargeur standard. */
Factory::factory( );

/* Configuration de base des chargeurs de librairies. */
Factory::factory( [
    'Zend\Loader\StandardAutoloader' => [
        PsrLoader::AUTOREGISTER_ZF => TRUE,
    ],
]);

et dans le repertoire config de mon projet j'ai mon site.php

Code:

[lang=php]
<?php

return [

    /* Configuration des Listerners du ModuleManager. */
    'module_listener_options' => [
        'module_paths' => [
            PATH_ROOT.'/modules',
        ],
    ],

    /* Modules à charger. */
    'modules' => [
         'Application',
        'Contact'
        /*'Contract',
        'Customer',
        'Dashboard',
        'Device',
        'Excel',
        'Login',
        'Tickets',
        'Validation',*/
    ],

    'service_manager' => [
        'factories' => [
            'Db' => 'Zend\Db\Adapter\AdapterServiceFactory',
        ]
    ],
    'db' => [
        'driver'   => 'PDO Mysql',
        'host'     => 'localhost',
        'dbname'   => 'webmrl',
        'username' => 'root',
        'password' => ''
    ],
];

Hors ligne

 

Pied de page des forums

Propulsé par PunBB
© Copyright 2002–2005 Rickard Andersson
Traduction par punbb.fr

Graphisme réalisé par l'agence Rodolphe Eveilleau
Développement par Kitpages