问题描述
php bin/console debug:router |grep postboxmessage
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 router:match/en/admin/app/postboxthread/{id}/postboxmessage/list
php bin/console router:match /en/admin/app/postboxthread/{id}/postboxmessage/list
[OK] 路由en__RG__admin_app_postboxthread_postboxmessage_list"匹配
[OK] Route "en__RG__admin_app_postboxthread_postboxmessage_list" matches
+--------------+-------------------------------------------------------------------------------------------+
| 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 | Symfony\Component\Routing\Route |
| Defaults | _controller: Mea\PostBoxBundle\Sonata\Controller\PostBoxMessageCrudController::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: Symfony\Component\Routing\RouteCompiler |
+--------------+-------------------------------------------------------------------------------------------+
这个例子部分工作,但这条路线我猜:)
This example partial work, but this route I guessed :)
PostBoxThreadAdmin
PostBoxThreadAdmin
/**
* {@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]));
$menu->addChild('Messages', $admin->generateMenuUrl('mea.postbox.sonata.admin.message.list', ['id' => $id]) );
显示子面板,但是当我创建新的并保存时 - 我得到 p>
child panel is shown but when i create new and save - i get
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.sonata.admin.message 但无法访问
So Sonata try use route _sonata_admin: mea.postbox.sonata.admin.thread|mea.postbox.sonata.admin.message but is not accessible
推荐答案
你可以这样做:
'uri' => str_replace('{id}',$id,'/admin/app/property/{id}/property-media/list')
如果您需要路线,可以通过以下方式找到:
If you need the route, you can find it with:
bin/console debug:router
这篇关于SonataAdmin 子管理路由在调试中可见但未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!