文件和目录结构

Note

此页面的内容需要进行重大更新。旧页面包含过时且可能不准确的信息。您仍然可以在 Mautic Developer Documentation archived repository 中访问它。

如果您有兴趣帮助开发此页面和其他新内容的,请考虑加入文档编写工作。

请阅读 Contributing GuidelinesContributing to Mautic’s documentation 以开始您的贡献。

插件的目录结构会根据实现的特性而有所不同。

插件至少需要以下结构:

HelloWorldBundle/
Config/

config.php

HelloWorldBundle.php

HelloWorldBundle/Config/config.php 用于将插件注册到 Mautic,并定义路由、菜单项、服务和参数。

HelloWorldBundle.php 文件用于将 bundle 注册到 Symfony 的内核中。请扩展 MauticIntegrationsBundleBundleAbstractPluginBundle 类。

<?php
// plugins/HelloWorldBundle/HelloWorldBundle.php

namespace MauticPlugin\HelloWorldBundle;

use Mautic\IntegrationsBundle\Bundle\AbstractPluginBundle;

class HelloWorldBundle extends AbstractPluginBundle
{
    // Nothing more required
}

一个示例插件目录和文件结构可能如下所示:

HelloWorldBundle/
Assets/
images/

earth.png mars.png

css/

helloworld.css

js/

helloworld.js

Config/

config.php

Controller/

WorldController.php

Entity/

World.php

EventListener/

CampaignSubscriber.php

Form/
Type/

WorldType.php

Migrations/

Version_0_0_1.php

Model/

WorldModel.php

Helper/

TravelHelper.php

Security/
Permissions/

WorldPermissions.php

Translations/
en_US/

flashes.ini messages.ini

Tests/
Unit/
EventListener/

CampaignSubscriberTest.php

Helper/

TravelHelperTest.php

Functional/
Controller/

WorldControllerTest.php

Views/
World/

form.html.php index.html.php list.html.php

HelloWorldBundle.php