SonataAdmin子管理路由在调试中可见,但未找到



php bin/console debug:router|grep postboxmessage

pt__RG__admin_mea_postbox_postboxmessage_list                ANY        ANY      ANY    /admin/mea/postbox/postboxmessage/list                                                 
pl__RG__admin_mea_postbox_postboxmessage_list                ANY        ANY      ANY    /pl/admin/mea/postbox/postboxmessage/list                                              
en__RG__admin_mea_postbox_postboxmessage_list                ANY        ANY      ANY    /en/admin/mea/postbox/postboxmessage/list                                              
pt__RG__admin_mea_postbox_postboxmessage_create              ANY        ANY      ANY    /admin/mea/postbox/postboxmessage/create                                               
pl__RG__admin_mea_postbox_postboxmessage_create              ANY        ANY      ANY    /pl/admin/mea/postbox/postboxmessage/create                                            
en__RG__admin_mea_postbox_postboxmessage_create              ANY        ANY      ANY    /en/admin/mea/postbox/postboxmessage/create                                            
pt__RG__admin_mea_postbox_postboxmessage_batch               ANY        ANY      ANY    /admin/mea/postbox/postboxmessage/batch                                                
pl__RG__admin_mea_postbox_postboxmessage_batch               ANY        ANY      ANY    /pl/admin/mea/postbox/postboxmessage/batch                                             
en__RG__admin_mea_postbox_postboxmessage_batch               ANY        ANY      ANY    /en/admin/mea/postbox/postboxmessage/batch                                             
pt__RG__admin_mea_postbox_postboxmessage_edit                ANY        ANY      ANY    /admin/mea/postbox/postboxmessage/{id}/edit                                            
pl__RG__admin_mea_postbox_postboxmessage_edit                ANY        ANY      ANY    /pl/admin/mea/postbox/postboxmessage/{id}/edit                                         
en__RG__admin_mea_postbox_postboxmessage_edit                ANY        ANY      ANY    /en/admin/mea/postbox/postboxmessage/{id}/edit                                         
pt__RG__admin_mea_postbox_postboxmessage_delete              ANY        ANY      ANY    /admin/mea/postbox/postboxmessage/{id}/delete                                          
pl__RG__admin_mea_postbox_postboxmessage_delete              ANY        ANY      ANY    /pl/admin/mea/postbox/postboxmessage/{id}/delete                                       
en__RG__admin_mea_postbox_postboxmessage_delete              ANY        ANY      ANY    /en/admin/mea/postbox/postboxmessage/{id}/delete                                       
pt__RG__admin_mea_postbox_postboxmessage_export              ANY        ANY      ANY    /admin/mea/postbox/postboxmessage/export                                               
pl__RG__admin_mea_postbox_postboxmessage_export              ANY        ANY      ANY    /pl/admin/mea/postbox/postboxmessage/export                                            
en__RG__admin_mea_postbox_postboxmessage_export              ANY        ANY      ANY    /en/admin/mea/postbox/postboxmessage/export                                            
pt__RG__admin_mea_postbox_postboxmessage_send                ANY        ANY      ANY    /admin/mea/postbox/postboxmessage/send                                                 
pl__RG__admin_mea_postbox_postboxmessage_send                ANY        ANY      ANY    /pl/admin/mea/postbox/postboxmessage/send                                              
en__RG__admin_mea_postbox_postboxmessage_send                ANY        ANY      ANY    /en/admin/mea/postbox/postboxmessage/send                                              
pt__RG__admin_app_postboxthread_postboxmessage_list          ANY        ANY      ANY    /admin/app/postboxthread/{id}/postboxmessage/list                                      
pl__RG__admin_app_postboxthread_postboxmessage_list          ANY        ANY      ANY    /pl/admin/app/postboxthread/{id}/postboxmessage/list                                   
en__RG__admin_app_postboxthread_postboxmessage_list          ANY        ANY      ANY    /en/admin/app/postboxthread/{id}/postboxmessage/list                                   
pt__RG__admin_app_postboxthread_postboxmessage_create        ANY        ANY      ANY    /admin/app/postboxthread/{id}/postboxmessage/create                                    
pl__RG__admin_app_postboxthread_postboxmessage_create        ANY        ANY      ANY    /pl/admin/app/postboxthread/{id}/postboxmessage/create                                 
en__RG__admin_app_postboxthread_postboxmessage_create        ANY        ANY      ANY    /en/admin/app/postboxthread/{id}/postboxmessage/create                                 
pt__RG__admin_app_postboxthread_postboxmessage_batch         ANY        ANY      ANY    /admin/app/postboxthread/{id}/postboxmessage/batch                                     
pl__RG__admin_app_postboxthread_postboxmessage_batch         ANY        ANY      ANY    /pl/admin/app/postboxthread/{id}/postboxmessage/batch                                  
en__RG__admin_app_postboxthread_postboxmessage_batch         ANY        ANY      ANY    /en/admin/app/postboxthread/{id}/postboxmessage/batch                                  
pt__RG__admin_app_postboxthread_postboxmessage_edit          ANY        ANY      ANY    /admin/app/postboxthread/{id}/postboxmessage/{childId}/edit                            
pl__RG__admin_app_postboxthread_postboxmessage_edit          ANY        ANY      ANY    /pl/admin/app/postboxthread/{id}/postboxmessage/{childId}/edit                         
en__RG__admin_app_postboxthread_postboxmessage_edit          ANY        ANY      ANY    /en/admin/app/postboxthread/{id}/postboxmessage/{childId}/edit                         
pt__RG__admin_app_postboxthread_postboxmessage_delete        ANY        ANY      ANY    /admin/app/postboxthread/{id}/postboxmessage/{childId}/delete                          
pl__RG__admin_app_postboxthread_postboxmessage_delete        ANY        ANY      ANY    /pl/admin/app/postboxthread/{id}/postboxmessage/{childId}/delete                       
en__RG__admin_app_postboxthread_postboxmessage_delete        ANY        ANY      ANY    /en/admin/app/postboxthread/{id}/postboxmessage/{childId}/delete                       
pt__RG__admin_app_postboxthread_postboxmessage_show          ANY        ANY      ANY    /admin/app/postboxthread/{id}/postboxmessage/{childId}/show                            
pl__RG__admin_app_postboxthread_postboxmessage_show          ANY        ANY      ANY    /pl/admin/app/postboxthread/{id}/postboxmessage/{childId}/show                         
en__RG__admin_app_postboxthread_postboxmessage_show          ANY        ANY      ANY    /en/admin/app/postboxthread/{id}/postboxmessage/{childId}/show                         
pt__RG__admin_app_postboxthread_postboxmessage_export        ANY        ANY      ANY    /admin/app/postboxthread/{id}/postboxmessage/export                                    
pl__RG__admin_app_postboxthread_postboxmessage_export        ANY        ANY      ANY    /pl/admin/app/postboxthread/{id}/postboxmessage/export                                 
en__RG__admin_app_postboxthread_postboxmessage_export        ANY        ANY      ANY    /en/admin/app/postboxthread/{id}/postboxmessage/export     

php-bin/console路由器:match/en/admin/app/postboxthread/{id}/postboxmessage/list

[OK]路由"en__RG__admin_app_postboxthread_postboxmessage_list"与匹配

+--------------+-------------------------------------------------------------------------------------------+
| Property     | Value                                                                                     |
+--------------+-------------------------------------------------------------------------------------------+
| Route Name   | en__RG__admin_app_postboxthread_postboxmessage_list                                       |
| Path         | /en/admin/app/postboxthread/{id}/postboxmessage/list                                      |
| Path Regex   | #^/en/admin/app/postboxthread/(?P<id>[^/]++)/postboxmessage/list$#sD                      |
| Host         | ANY                                                                                       |
| Host Regex   |                                                                                           |
| Scheme       | ANY                                                                                       |
| Method       | ANY                                                                                       |
| Requirements | NO CUSTOM                                                                                 |
| Class        | SymfonyComponentRoutingRoute                                                           |
| Defaults     | _controller: MeaPostBoxBundleSonataControllerPostBoxMessageCrudController::listAction |
|              | _locale: en                                                                               |
|              | _sonata_admin: mea.postbox.sonata.admin.thread|mea.postbox.sonata.admin.message           |
|              | _sonata_name: admin_app_postboxthread_postboxmessage_list                                 |
| Options      | compiler_class: SymfonyComponentRoutingRouteCompiler                                   |
+--------------+-------------------------------------------------------------------------------------------+

这个例子部分工作,但这个路线我猜:(

邮箱线程管理

/**
* {@inheritdoc}
*/
protected function configureTabMenu(MenuItemInterface $menu, $action, AdminInterface $childAdmin = null): void
{
if (!$childAdmin && !in_array($action, ['edit'])) {
return;
}
$admin = $this->isChild() ? $this->getParent() : $this;
$id = $admin->getRequest()->get('id');
if ($this->isGranted('EDIT')) {
$menu->addChild('Edit Thread', [
'uri' => $admin->generateUrl('edit', ['id' => $id])
]);
}
$menu->addChild('Messages',
$admin->generateMenuUrl('mea.postbox.sonata.admin.message.list', ['id' => $id])
);
}

当我尝试时

$menu->addChild('Messages',
$admin->generateMenuUrl('mea.postbox.sonata.admin.message', ['id' => $id])
);

获取

An exception has been thrown during the rendering of a template ("unable to find the route `mea.postbox.sonata.admin.thread|mea.postbox.sonata.admin.message`").

尝试

$menu->addChild('Messages',
$admin->generateMenuUrl('mea.postbox.sonata.admin.thread|mea.postbox.sonata.admin.message', ['id' => $id])
);

获取

An exception has been thrown during the rendering of a template ("unable to find the route `mea.postbox.sonata.admin.thread|mea.postbox.sonata.admin.thread|mea.postbox.sonata.admin.message`").

尝试

$menu->addChild('Messages',
$admin->generateMenuUrl('admin_app_postboxthread_postboxmessage_list', ['id' => $id])
);

获取

An exception has been thrown during the rendering of a template ("unable to find the route `mea.postbox.sonata.admin.thread.admin_app_postboxthread_postboxmessage_list`").

当我使用时

$menu->addChild("消息",$admin->generateMenuUrl('mea.postbox.sonata.admin.message.list',['id'=>$id]();

显示子面板,但当我创建新面板并保存时,我得到

unable to find the route `mea.postbox.sonata.admin.thread|mea.postbox.sonata.admin.message.send`
RuntimeException
in vendor/sonata-project/admin-bundle/src/Route/DefaultRouteGenerator.php (line 109)
in vendor/sonata-project/admin-bundle/src/Route/DefaultRouteGenerator.php->generateMenuUrl (line 60)
in vendor/Mea/PostBoxBundle/Sonata/Admin/PostBoxMessageAdmin.php->generateUrl (line 190)
in vendor/sonata-project/admin-bundle/src/Admin/AbstractAdmin.php->configureFormFields (line 1267)
in vendor/sonata-project/admin-bundle/src/Admin/AbstractAdmin.php->defineFormBuilder (line 1254)
in vendor/sonata-project/admin-bundle/src/Admin/AbstractAdmin.php->getFormBuilder (line 2980)
in vendor/sonata-project/admin-bundle/src/Admin/AbstractAdmin.php->buildForm (line 1311)
in vendor/sonata-project/admin-bundle/src/Controller/CRUDController.php->getForm (line 336)
in vendor/symfony/http-kernel/HttpKernel.php->editAction (line 149)
in vendor/symfony/http-kernel/HttpKernel.php->handleRaw (line 66)
in vendor/symfony/http-kernel/Kernel.php->handle (line 188)
Kernel->handle(object(Request))
in public/index.php (line 37)
Request::setTrustedHosts(explode(',', $trustedHosts));}$kernel = new Kernel($env, $debug);$request = Request::createFromGlobals();$response = $kernel->handle($request);$response->send();$kernel->terminate($request, $response);

因此,Sonata尝试使用路由_Sonata_admin:mea.postbox.Sonata.admin.thread|mea.postbox.onata.admin.message,但无法访问

你可以这样做:

'uri' => str_replace('{id}',$id,'/admin/app/property/{id}/property-media/list')

如果你需要路线,你可以用找到

bin/console debug:router

相关内容

  • 没有找到相关文章

最新更新