1

我试图在我的 symfony2.1 项目中使用以下两个包:

我的问题是,这两个捆绑包都使用knp-menu bundle。但是奏鸣曲需要 1.1.x-dev 的 knp-menu 包和精心设计的 bootstrap-bundle dev-master。

使用以下作曲家设置,我收到以下错误。作曲家.json:

    "sonata-project/admin-bundle": "dev-master",
    "sonata-project/doctrine-orm-admin-bundle": "dev-master",
    "sonata-project/intl-bundle": "dev-master",
    "sonata-project/cache-bundle": "dev-master",
    "knplabs/knp-menu-bundle": "1.1.x-dev",
    "braincrafted/bootstrap-bundle": "dev-develop"

错误:在 vendor/braincrafted/bootstrap-bundle/Braincrafted/BootstrapBundle/Voter/RequestVoter 中找不到 Knp\Menu\Matcher\Voter\VoterInterface'

我知道早期的 knp 菜单捆绑版本中不存在 Matcher。但是,如果我将 knp 菜单包版本更改为:

“knplabs/knp-menu-bundle”:“开发大师”,

无法安装奏鸣曲管理包。如果我执行命令“composer.phar update”,会出现以下错误

  Problem 1
    - sonata-project/admin-bundle dev-master requires knplabs/knp-menu-bundle >=1.1.0,<2.0.x-dev -> satisfiable by knplabs/knp-menu-bundle 1.1.x-dev, knplabs/knp-menu-bundle 1.1.x-dev, knplabs/knp-menu-bundle v1.1.0.
    - sonata-project/admin-bundle dev-master requires knplabs/knp-menu-bundle >=1.1.0,<2.0.x-dev -> satisfiable by knplabs/knp-menu-bundle 1.1.x-dev, knplabs/knp-menu-bundle 1.1.x-dev, knplabs/knp-menu-bundle v1.1.0.
    - Can only install one of: knplabs/knp-menu-bundle dev-master, knplabs/knp-menu-bundle 1.1.x-dev.
    - Can only install one of: knplabs/knp-menu-bundle dev-master, knplabs/knp-menu-bundle 1.1.x-dev.
    - Can only install one of: knplabs/knp-menu-bundle v1.1.0, knplabs/knp-menu-bundle dev-master.
    - Installation request for knplabs/knp-menu-bundle dev-master -> satisfiable by knplabs/knp-menu-bundle dev-master.
    - Installation request for sonata-project/admin-bundle dev-master -> satisfiable by sonata-project/admin-bundle dev-master.

有人知道我如何使用这两个捆绑包还是没有办法?感谢帮助。

4

3 回答 3

1

编辑 composer.json 并参考 knp-menu-bundle 修改该行,如下所示: "knplabs/knp-menu-bundle": "1.1.x-dev",

它需要一个 >=1.1.0,<2.0.x-dev 的版本,该版本在错误的第一行中说明。

这对我行得通。

于 2013-04-16T06:38:53.740 回答
0

使用 Composer,您不能同时使用这两个包。其实你应该在https://github.com/braincrafted/bootstrap-bundle开一张票并说明情况。他们应该更新项目的 composer.json 以允许人们使用当前版本的 KnpMenu 而不仅仅是最新版本。

于 2013-02-18T14:33:10.733 回答
0

我找到了一个临时解决方案来使用这两个捆绑包,直到这张得到解决。

我在 composer.json 文件中定义了一个存储库并操作了奏鸣曲管理包要求(“knplabs/knp-menu-bundle”:“dev-master”):

"repositories": [
{
    "type": "package",             
    "package": {
        "name": "sonata-project/admin-bundle",
        "type": "symfony-bundle",
        "description": "Symfony SonataAdminBundle",
        "keywords": ["Admin Generator", "admin", "sonata", "bootstrap"],
        "homepage": "http://sonata-project.org/bundles/admin",
        "license": "MIT",
        "authors": [
        {
            "name": "Thomas Rabaix",
            "email": "thomas.rabaix@sonata-project.org",
            "homepage": "http://sonata-project.org"
        },
        {
            "name": "Sonata Community",
            "homepage": "https://github.com/sonata-project/SonataAdminBundle/contributors"
        }
        ],
        "require": {
            "symfony/http-foundation": ">=2.1,<2.3-dev",
            "symfony/form": ">=2.1,<2.3-dev",
            "symfony/validator": ">=2.1,<2.3-dev",
            "symfony/security-bundle": ">=2.1,<2.3-dev",
            "symfony/routing": ">=2.1,<2.3-dev",
            "symfony/config": ">=2.1,<2.3-dev",
            "symfony/console": ">=2.1,<2.3-dev",
            "symfony/twig-bridge": ">=2.1,<2.3-dev",
            "twig/twig": ">=1.10,<2.0-dev",
            "knplabs/knp-menu-bundle": "dev-master",
            "sonata-project/jquery-bundle": "dev-master",
            "sonata-project/exporter": "dev-master",
            "sonata-project/block-bundle": "dev-master",
            "doctrine/common": ">=2.2,<3.0"
        },
        "require-dev": {
            "jms/translation-bundle": "*"
        },
        "suggest": {
            "sonata-project/doctrine-orm-admin-bundle": "dev-master",
            "sonata-project/intl-bundle": "dev-master"
        },
        "autoload": {
            "psr-0": {
                "Sonata\\AdminBundle": ""
            }
        },
        "target-dir": "Sonata/AdminBundle",            
        "version": "dev-master",
        "source": {
            "url": "git://github.com/sonata-project/SonataAdminBundle.git",
            "type": "git",
            "reference": "0269691d61764798537a2fd3b13bfafbfb387eef"
        }                   

    }
}

然后我不得不覆盖管理类中的 buildSideMenu 方法,因为方法 setCurrentUri() 不再存在(现在命名为 setUri())。我自己的所有管理类现在都扩展了 MyAdmin

abstract class MyAdmin extends Admin
{

    /**
     * Build the side menu related to the current action
     *
     * @param string                                   $action
     * @param \Sonata\AdminBundle\Admin\AdminInterface $childAdmin
     *
     * @return \Knp\Menu\ItemInterface|boolean
     */
    public function buildSideMenu($action, AdminInterface $childAdmin = null)
    {
        if ($this->loaded['side_menu']) {
            return;
        }

        $this->loaded['side_menu'] = true;

        $menu = $this->menuFactory->createItem('root');
        $menu->setChildrenAttribute('class', 'nav nav-list');
        $menu->setUri($this->getRequest()->getBaseUrl().$this->getRequest()->getPathInfo());

        $this->configureSideMenu($menu, $action, $childAdmin);

        foreach ($this->getExtensions() as $extension) {
            $extension->configureSideMenu($this, $menu, $action, $childAdmin);
        }

        $this->menu = $menu;
    }


}

我知道这不是最好的解决方案,但它适用于我的目的

于 2013-05-03T14:19:17.637 回答