0

我正在尝试创建自己的 pimcore 包。但是现在我的安装程序类有问题。当我尝试安装我的捆绑包时,会出现此错误消息:

Message: You have requested a non-existent service "Pimcore\Bundle\TestBundle\Tools\Installer". Did you mean this: "Pimcore\Bundle\EcommerceFrameworkBundle\Tools\Installer"?

这是我的代码:

测试包

<?php

namespace Pimcore\Bundle\TestBundle;

use Pimcore\Bundle\TestBundle\Tools\Installer;
use Pimcore\Extension\Bundle\AbstractPimcoreBundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;

/**
 * Class TestBundle
 * @package Pimcore\Bundle\TestBundle
 */
class TestBundle extends AbstractPimcoreBundle
{

    const BUNDLE_NAME = "TestBundle";
    const BUNDLE_DESCRIPTION = "Just a test!";
    const BUNDLE_VERSION = "1.0";

    /**
     * @inheritDoc
     */
    public function getNiceName()
    {
        return self::BUNDLE_NAME;
    }

    /**
     * @inheritDoc
     */
    public function getDescription()
    {
        return self::BUNDLE_DESCRIPTION;
    }

    /**
     * @inheritDoc
     */
    public function build(ContainerBuilder $container)
    {

    }

    /**
     * @inheritDoc
     */
    public function getVersion()
    {
        return self::BUNDLE_VERSION;
    }

    /**
     * @return array
     */
    public function getCssPaths()
    {
        return [
            '/bundles/' . strtolower(self::BUNDLE_NAME) . '/css/pricing.css'
        ];
    }

    /**
     * @return array
     */
    public function getJsPaths()
    {
        return [];
    }


    /**
     * @return Installer
     */
    public function getInstaller()
    {
         return $this->container->get(Installer::class);
    }
}

安装程序

<?php

namespace Pimcore\Bundle\TestBundle\Tools;

use Pimcore\Extension\Bundle\Installer\AbstractInstaller;
use Psr\Log\LoggerInterface;

class Installer extends AbstractInstaller
{

    public function __construct(LoggerInterface $logger)
    {

    }

    /**
     * installs e-commerce framework
     *
     * @throws \Exception
     */
    public function install()
    {


    }

    /**
     * @return bool
     */
    public function canBeInstalled()
    {

    }

    /**
     * checks, if install is possible. otherwise throws exception
     *
     * @throws \Exception
     */
    protected function checkCanBeInstalled()
    {

    }

    public function canBeUninstalled()
    {
        return true;
    }

    /**
     * uninstalls e-commerce framework
     */
    public function uninstall()
    {

    }

    /**
     *
     * @return bool
     */
    public function needsReloadAfterInstall()
    {
        return true;
    }

    /**
     *  indicates if this bundle is currently installed
     *
     * @return bool
     */
    public function isInstalled()
    {

    }
}

Services.yml(在 /Resources/config 下)

services:
    _defaults:
        public: true
        autowire: true
        autoconfigure: true


    #
    # INSTALLER
    #

    pimcore.testbundle.installer: '@Pimcore\Bundle\TestBundle\Tools\Installer'
    Pimcore\Bundle\TestBundle\Tools\Installer:
        tags:
            - { name: monolog.logger, channel: pimcore_testbundle.installer }

    #
    # CONTROLLERS
    #

    # auto-register all controllers as services
    Pimcore\Bundle\TestBundle\Controller\:
        resource: '../../Controller'
        public: true
        tags: ['controller.service_arguments']

我试图这样做很长时间,但它仍然不起作用。不幸的是,我在官方 pimcore 文档中找不到记录的内容。

非常感谢!

4

1 回答 1

1

对我来说,您似乎试图手动复制电子商务捆绑包。从理论上讲,它应该可以工作,但可以肯定的是,集成到 pimcore 目录中并不是最好的主意。

要生成新包,您应该bin/console pimcore:generate:bundle在 CLI 中使用(更多信息:https ://pimcore.com/docs/5.0.x/Extending_Pimcore/Bundle_Developers_Guide/index.html )

dev(!)请注意,此命令仅适用于test环境(请参阅https://github.com/pimcore/pimcore/blob/master/pimcore/lib/Pimcore/Kernel.php#L212

于 2017-11-09T07:37:16.353 回答