Skip to main content
Version: 2024.1

Implement Custom Environment Variable Types

To create a custom environment variable type, create a class that extends [Pimcore\Bundle\CopilotBundle\AutomationAction\Configuration\Environment\AbstractEnvironment] and implement the configureEnvironment method. The options for the configuration can be defined using The OptionsResolver Component from symfony.

The type returned by the getType method needs to be one of the following:

  • text
  • number
  • date
  • checkbox
  • select
  • matrix

final class CustomStringType extends AbstractEnvironment
{
public function getType(): string
{
return 'string';
}

protected function configureEnvironment(): void
{
$this->environmentConfiguration->setRequired('required');
$this->environmentConfiguration->setAllowedTypes('required', 'bool');

$this->environmentConfiguration->setRequired('values');
$this->environmentConfiguration->setAllowedTypes('values', 'array');
}
protected getInlineHelpTemplateFileName(): string {
// optional overwrite this method to specify path of twig file used for inline help
// default implementations points to @PimcoreCopilot/InlineHelp/AutomationAction/EnvironmentVariable/<TYPE>.html.twig'
}
}

The extended class then needs to be registered as a symfony service and tagged with pimcore.copilot.automation_action.configuration_environment_type.

services:
App\AutomationAction\Configuration\Environment\CustomStringType:
tags:
- { name: pimcore.copilot.automation_action.configuration_environment_type }

Inline Help Data

To add inline help data for your custom type, you need to provide a twig template that will be used to render the help data in the UI. The path to the template needs to be returned by the getInlineHelpTemplateFileName method of your custom type implementation. By default @PimcoreCopilot/InlineHelp/AutomationAction/EnvironmentVariable/<TYPE>.html.twig is used.