Skip to content

Commit

Permalink
Allow acl_protected changes for Akeneo attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
dxops committed Jan 15, 2021
1 parent 57ece95 commit 30de959
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Form/Extension/AttachmentAclExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Oro\Bundle\AkeneoBundle\Form\Extension;

use Oro\Bundle\EntityConfigBundle\Entity\FieldConfigModel;
use Oro\Bundle\EntityConfigBundle\Form\Type\ConfigType;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\FormBuilderInterface;

/**
* Allow `acl_protected` changes for Akeneo fields
*/
class AttachmentAclExtension extends AbstractTypeExtension
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$configModel = $options['config_model'];
if ($configModel instanceof FieldConfigModel) {
$data = $builder->getData();
if (($data['importexport']['source'] ?? null) === 'akeneo') {
$builder->get('attachment')->get('acl_protected')->setDisabled(false);
}
}
}

public static function getExtendedTypes(): iterable
{
return [ConfigType::class];
}
}
5 changes: 5 additions & 0 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ services:
tags:
- { name: form.type_extension, extended_type: Oro\Bundle\IntegrationBundle\Form\Type\ChannelType }

oro_akeneo.form.extension.attachment_acl_extension:
class: 'Oro\Bundle\AkeneoBundle\Form\Extension\AttachmentAclExtension'
tags:
- { name: form.type_extension, alias: oro_entity_config_type, extended_type: Oro\Bundle\EntityConfigBundle\Form\Type\ConfigType }

oro_akeneo.form.extension.product_type:
class: Oro\Bundle\AkeneoBundle\Form\Extension\ProductTypeExtension
arguments:
Expand Down

0 comments on commit 30de959

Please sign in to comment.