Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Updated documentation for the ConfigFormNotesInterface usages. #214

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions source/includes/_plugin_integrations_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,8 @@ Currently the integrations bundle provides default features. To use these featur
The integrations bundle provides a sync framework for 3rd party services to sync with Mautic's contacts and companies. The `\Mautic\IntegrationsBundle\Integration\Interfaces\ConfigFormSyncInterface` determines the configuration options for this sync feature. Refer to the method docblocks in the interface for more details.

Read more about how to leverage the [sync framework](#integration-sync-engine).

##### Config Form Notes Interface
The interface, `\Mautic\IntegrationsBundle\Integration\Interfaces\ConfigFormNotesInterface`, provides a way to put notes, either info or warning, on the plugin configuration form.

Read more about to how tos [here](#integration-configuration-form-notes)
77 changes: 77 additions & 0 deletions source/includes/_plugin_integrations_configuration_form_notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
### Integration Configuration Form Notes

The integration framework lets developer define their custom messages for the plugin's configuration form.

The `ConfigSupport` class should implement the `\Mautic\IntegrationsBundle\Integration\Interfaces\ConfigFormNotesInterface`.

```php
<?php

declare(strict_types=1);

namespace MauticPlugin\HelloWorldBundle\Integration\Support;

use Mautic\IntegrationsBundle\DTO\Note;
use Mautic\IntegrationsBundle\Integration\ConfigFormNotesTrait;
use Mautic\IntegrationsBundle\Integration\DefaultConfigFormTrait;
use Mautic\IntegrationsBundle\Integration\Interfaces\ConfigFormAuthInterface;
use Mautic\IntegrationsBundle\Integration\Interfaces\ConfigFormFeatureSettingsInterface;
use Mautic\IntegrationsBundle\Integration\Interfaces\ConfigFormFeaturesInterface;
use Mautic\IntegrationsBundle\Integration\Interfaces\ConfigFormInterface;
use Mautic\IntegrationsBundle\Integration\Interfaces\ConfigFormNotesInterface;
use Mautic\IntegrationsBundle\Integration\Interfaces\ConfigFormSyncInterface;
use MauticPlugin\HelloWorldBundle\Form\Type\ConfigAuthType;
use MauticPlugin\HelloWorldBundle\Form\Type\ConfigFeaturesType;
use MauticPlugin\HelloWorldBundle\Integration\HelloWorldIntegration;

class ConfigSupport extends HelloWorldIntegration implements ConfigFormInterface, ConfigFormAuthInterface, ConfigFormFeatureSettingsInterface, ConfigFormSyncInterface, ConfigFormFeaturesInterface, ConfigFormNotesInterface
{
use DefaultConfigFormTrait;
use ConfigFormNotesTrait;

public function getAuthConfigFormName(): string
{
return ConfigAuthType::class;
}

public function getFeatureSettingsConfigFormName(): string
{
return ConfigFeaturesType::class;
}

// ...

/**
* Adds message to the Enable/Auth tab.
*/
public function getAuthorizationNote(): ?Note
{
return new Note('Additional information for Authorization tab.', Note::TYPE_INFO);
}

/**
* Adds message to the Features tab.
*/
public function getFeaturesNote(): ?Note
{
return new Note('Warning message for Features tab.', Note::TYPE_WARNING);
}

/**
* Adds message to the Field Mapping tabs.
*/
public function getFieldMappingNote(): ?Note
{
return new Note('Additional information for Field mapping tab.', Note::TYPE_INFO);
}
}
```

Some pointers,
* The trait `Mautic\IntegrationsBundle\Integration\ConfigFormNotesTrait` helps define the default `null`.
* Instead of plain string, one can pass the translation key which holds the message. eg. `new Note('helloworld.config.auth_tab', Note::TYPE_INFO);`