你好,Pimcore开发人员,我正在从事一个运行在Pimcore X上的项目!但我又遇到了一些“麻烦”。当我试图到达控制器时,我会得到错误消息:"App\Foo\Bar\Controller\SomeController" has no container set, did you forget to define it as a service subscriber?
让我展示一些代码片段:
src\Foo\Bar\Controller\SomeController
namespace App\Foo\Bar\Controller;
/**
* @Route("/admin/Bar")
*/
class SomeController extends AdminController
{
/**
* @Route("/foo", name="foo-you-too")
*
* @return Response
*/
public function someAction(): Response
{
die('howdy!');
}
}src\Foo\Bar\DependencyInjection\BarBundleExtension
namespace App\Foo\Bar\DependencyInjection;
class BarBundleExtension extends ConfigurableExtension implements PrependExtensionInterface
{
/**
* {@inheritdoc}
*/
public function loadInternal(array $config, ContainerBuilder $container)
{
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
}
}src/Foo/Bar/Resources/config/services.yml
services:
_defaults:
autowire: true
autoconfigure: true
public: false
#Foo\Bar\Controller\:
#App\Bar\Controller\:
App\Foo\Bar\Controller\:
resource: '../../Controller'
public: true
autowire: true
autoconfigure: true
tags: ['controller.service_arguments']src/Foo/Bar/Resources/config/pimcore/routing.yml
app:
resource: "@Bar/Controller/"
type: annotationsrc/Foo/Bar/Resources/public/js/startup.js
pimcore.registerNS("pimcore.plugin.menusample");
pimcore.plugin.menusample = Class.create(pimcore.plugin.admin, {
getClassName: function () {
return "pimcore.plugin.menusample";
},
initialize: function () {
pimcore.plugin.broker.registerPlugin(this);
this.navEl = Ext.get('pimcore_menu_search').insertSibling('<li id="pimcore_menu_mds" class="pimcore_menu_item pimcore_menu_needs_children">Howdy there!</li>', 'after');
this.menu = new Ext.menu.Menu({
items: [{
text: "Some text",
iconCls: "pimcore_icon_apply",
handler: function (button) {
new Ext.Window({
title: t('-'),
width: '50%',
height: '80%',
layout: 'fit',
items: [
{
xtype: "component",
autoEl: {
tag: "iframe",
src: "/admin/Bar/foo"
},
border: false
}
]
}).show();
}.bind(this)
}],
cls: "pimcore_navigation_flyout"
});
pimcore.layout.toolbar.prototype.mdsMenu = this.menu;
},
pimcoreReady: function (params, broker) {
var toolbar = pimcore.globalmanager.get("layout_toolbar");
this.navEl.on("mousedown", toolbar.showSubMenu.bind(toolbar.mdsMenu));
pimcore.plugin.broker.fireEvent("mdsMenuReady", toolbar.mdsMenu);
}
});
const menusamplePlugin = new pimcore.plugin.menusample();我怀疑我的services.yml有什么问题,我已经找过类似的StackOverflow问题了,但没有结果。
发布于 2022-02-17 10:20:40
我找到了解决方案-- DependencyInjection类名的名称是错误的--应该是BarExtension而不是BarBundleExtension,就像名称空间中的那样。
https://stackoverflow.com/questions/71155078
复制相似问题