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

时间:2017-11-01 16:46:02

标签: nginx php-7 pimcore bundles pimcore-v5

我试图创建自己的pimcore包。但是现在我的安装程序类有问题。当我尝试安装我的软件包时,会出现以下错误消息:

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

这是我的代码:

TestBundle

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

非常感谢!

1 个答案:

答案 0 :(得分:1)

对我而言,您似乎尝试手动复制电子商务套装。从理论上讲,它应该可以工作,但可以肯定的是,将它集成到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