小编khu*_*uri的帖子

Zend框架无法路由已翻译的子路由

我是Zend框架3的新手,并试图翻译路线,我已经部分成功.我能够翻译主路线并将其重定向到所需的位置,但对于子路线,翻译工作但重定向不起作用.能帮到我吗,我的代码如下.

module.config.php

'router' => [
        'router_class'           => TranslatorAwareTreeRouteStack::class,
        'routes' => [
            'setting' => [
                'type'    => Segment::class,
                'options' => [
                    'route' => '/{locale}/{setting}',

                    'defaults' => [
                        'locale'     => 'de',
                        'controller' => Controller\SettingController::class,
                        'action'     => 'index',
                    ],
                ],

                'may_terminate'=>true,
                 'child_routes' =>[
                        'add' =>[
                            'type'      =>'Segment',
                            'options'   =>[
                                'route'         =>'/{add}',
                                'defaults'=> [
                                     'controller' => Controller\SettingController::class,
                                     'action'     => 'add',
                                ],
                            ],  
                        ],
                 ],
            ],
        ],
    ],
Run Code Online (Sandbox Code Playgroud)

Module.php

   public function onBootstrap(MvcEvent $e)
    {
        $eventManager        = $e->getApplication()->getEventManager();
        $moduleRouteListener = new ModuleRouteListener();
        $moduleRouteListener->attach($eventManager);

        $language_session = new …
Run Code Online (Sandbox Code Playgroud)

php zend-translate zend-route zend-framework2 zend-framework3

5
推荐指数
1
解决办法
476
查看次数

Zf3控制器无法访问位于另一个模块中的模型类表

我是Zend Framework的新手.有没有办法从我的活动控制器访问位于另一个模块中的模型类表?作为ZF3中的再见服务定位器,我无法访问位于其他模块中的模型类表.

以前在ZF2控制器中

private configTable;

public function getConfigTable()
{
    if (!$this->configTable) {
        $sm = $this->getServiceLocator();
        $this->configTable = $sm->get('Config\Model\ConfigTable'); // <-- HERE!
    }
    return $this->configTable;
}

public function indexAction(){
     $allConfig = $this->getConfigTable()->getAllConfiguration();
    ......

}
Run Code Online (Sandbox Code Playgroud)

由于服务定位器足以将函数从控制器调用到位于另一个模块中的模型类.有没有办法在没有服务定位器的ZF3中实现类似的东西?

先谢谢你们.再见!

php zend-framework zend-controller zend-framework2 zend-framework3

2
推荐指数
1
解决办法
2380
查看次数