Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update custom channel docs, resolves #493 #494

Merged
merged 1 commit into from
Nov 26, 2024
Merged
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
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
Loading