Pimcore 没有为我的安装程序创建服务 class

Pimcore doesn't create a service of my installer class

我正在尝试创建自己的 pimcore 包。但现在我的安装程序出现问题 class。当我尝试安装我的包时出现此错误消息:

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 文档中记录的内容。

非常感谢!

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

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

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