Skip to content

Commit

Permalink
update custom channel docs, resolves #493 (#494)
Browse files Browse the repository at this point in the history
  • Loading branch information
solverat authored Nov 26, 2024
1 parent 5b1899e commit 8c0f31e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 32 deletions.
3 changes: 3 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Upgrade Notes

## 5.1.5
- **[BUGFIX]** Update custom channel docs [#493](https://github.com/dachcom-digital/pimcore-formbuilder/issues/493)

## 5.1.4
- **[BUGFIX]** Allow using double-opt-in variables in placeholder processor

Expand Down
40 changes: 8 additions & 32 deletions docs/OutputWorkflow/12_CustomChannel.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,12 @@ use Symfony\Component\OptionsResolver\OptionsResolver;

class MyChannelType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('myConfigField', TextType::class);
}

/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([]);
}
Expand All @@ -58,48 +52,29 @@ use FormBuilderBundle\Form\FormValuesOutputApplierInterface;

class MyChannel implements ChannelInterface
{
/**
* @var FormValuesOutputApplierInterface
*/
protected $formValuesOutputApplier;

public function __construct(FormValuesOutputApplierInterface $formValuesOutputApplier)
public function __construct(protected FormValuesOutputApplierInterface $formValuesOutputApplier)
{
$this->formValuesOutputApplier = $formValuesOutputApplier;
}

/**
* {@inheritdoc}
*/
public function getFormType(): string
{
// you need to create a form type for backend configuration validation.
return MyChannelType::class;
}

/**
* {@inheritdoc}
*/
public function isLocalizedConfiguration(): bool
{
return false;
}

/**
* {@inheritdoc}
*/
public function getUsedFormFieldNames(array $channelConfiguration)
public function getUsedFormFieldNames(array $channelConfiguration): array
{
return [];
}

/**
* {@inheritdoc}
*/
public function dispatchOutputProcessing(SubmissionEvent $submissionEvent, string $workflowName, array $channelConfiguration)
public function dispatchOutputProcessing(SubmissionEvent $submissionEvent, string $workflowName, array $channelConfiguration): void
{
$formConfiguration = $submissionEvent->getFormConfiguration();
$locale = $submissionEvent->getRequest()->getLocale();
$locale = $submissionEvent->getLocale() ?? $submissionEvent->getRequest()->getLocale();
$form = $submissionEvent->getForm();

// Output Transformer (See section "Output Transformer" above).
Expand All @@ -112,7 +87,8 @@ class MyChannel implements ChannelInterface
```

## ExtJS Class
You need to register this class via `\Pimcore\Event\BundleManagerEvents::JS_PATHS` Event.
You need to register this class via `\Pimcore\Event\BundleManagerEvents::JS_PATHS` Event.
Make sure, that you've defined a low priority, to allow loading fb resources first!.

```js
pimcore.registerNS('Formbuilder.extjs.formPanel.outputWorkflow.channel.myChannel');
Expand Down

0 comments on commit 8c0f31e

Please sign in to comment.