Skip to content

Commit 815411c

Browse files
vesnacusticpspanja
authored andcommitted
IOTA-313 reset field type to simple ibexa TextBlock
1 parent 05504e2 commit 815411c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+715
-4285
lines changed

bundle/DependencyInjection/Configuration.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Netgen\IbexaFieldTypeEnhancedLinkBundle\DependencyInjection;
5+
namespace Netgen\IbexaFieldTypeHtmlTextBundle\DependencyInjection;
66

77
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
88
use Symfony\Component\Config\Definition\ConfigurationInterface;
@@ -11,11 +11,11 @@ class Configuration implements ConfigurationInterface
1111
{
1212
public function getAlias(): string
1313
{
14-
return 'netgen_ibexa_fieldtype_enhanced_link';
14+
return 'netgen_ibexa_fieldtype_html_text';
1515
}
1616

1717
public function getConfigTreeBuilder(): TreeBuilder
1818
{
19-
return new TreeBuilder('netgen_ibexa_fieldtype_enhanced_link');
19+
return new TreeBuilder('netgen_ibexa_fieldtype_html_text');
2020
}
2121
}

bundle/DependencyInjection/NetgenIbexaFieldTypeEnhancedLinkExtension.php renamed to bundle/DependencyInjection/NetgenIbexaFieldTypeHtmlTextExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Netgen\IbexaFieldTypeEnhancedLinkBundle\DependencyInjection;
5+
namespace Netgen\IbexaFieldTypeHtmlTextBundle\DependencyInjection;
66

77
use Symfony\Component\Config\FileLocator;
88
use Symfony\Component\Config\Resource\FileResource;
@@ -14,7 +14,7 @@
1414

1515
use function file_get_contents;
1616

17-
class NetgenIbexaFieldTypeEnhancedLinkExtension extends Extension implements PrependExtensionInterface
17+
class NetgenIbexaFieldTypeHtmlTextExtension extends Extension implements PrependExtensionInterface
1818
{
1919
/**
2020
* @throws \Exception

bundle/EventListener/UniversalDiscovery/AllowedContentTypes.php

-58
This file was deleted.

bundle/EventListener/UniversalDiscovery/StartingLocationId.php

-39
This file was deleted.

bundle/Form/Field/FieldValueFormMapper.php

+17-24
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,33 @@
22

33
declare(strict_types=1);
44

5-
namespace Netgen\IbexaFieldTypeEnhancedLinkBundle\Form\Field;
5+
namespace Netgen\IbexaFieldTypeHtmlTextBundle\Form\Field;
66

77
use Ibexa\ContentForms\FieldType\Mapper\AbstractRelationFormMapper;
88
use Ibexa\Contracts\ContentForms\Data\Content\FieldData;
99
use Symfony\Component\Form\FormInterface;
1010

1111
class FieldValueFormMapper extends AbstractRelationFormMapper
1212
{
13-
public function mapFieldValueForm(FormInterface $fieldForm, FieldData $data): void
13+
public function mapFieldValueForm(FormInterface $fieldForm, FieldData $data)
1414
{
1515
$fieldDefinition = $data->fieldDefinition;
1616
$formConfig = $fieldForm->getConfig();
17-
$fieldSettings = $fieldDefinition->getFieldSettings();
1817

19-
$fieldForm->add(
20-
$formConfig->getFormFactory()->createBuilder()
21-
->create(
22-
'value',
23-
FieldValueType::class,
24-
[
25-
'required' => $fieldDefinition->isRequired,
26-
'label' => $fieldDefinition->getName(),
27-
'default_location' => $this->loadDefaultLocationForSelection(
28-
$fieldSettings['selectionRoot'],
29-
$fieldForm->getConfig()->getOption('location'),
30-
),
31-
'root_default_location' => $fieldSettings['rootDefaultLocation'] ?? false,
32-
'enable_suffix' => $fieldSettings['enableSuffix'] ?? false,
33-
'target_internal' => $fieldSettings['allowedTargetsInternal'] ?? [],
34-
'target_external' => $fieldSettings['allowedTargetsExternal'] ?? [],
35-
],
36-
)
37-
->setAutoInitialize(false)
38-
->getForm(),
39-
);
18+
$fieldForm
19+
->add(
20+
$formConfig->getFormFactory()->createBuilder()
21+
->create(
22+
'value',
23+
FieldValueType::class,
24+
[
25+
'required' => $fieldDefinition->isRequired,
26+
'label' => $fieldDefinition->getName(),
27+
'rows' => $data->fieldDefinition->fieldSettings['textRows'],
28+
]
29+
)
30+
->setAutoInitialize(false)
31+
->getForm()
32+
);
4033
}
4134
}

bundle/Form/Field/FieldValueTransformer.php

+2-63
Original file line numberDiff line numberDiff line change
@@ -2,69 +2,8 @@
22

33
declare(strict_types=1);
44

5-
namespace Netgen\IbexaFieldTypeEnhancedLinkBundle\Form\Field;
5+
namespace Netgen\IbexaFieldTypeHtmlTextBundle\Form\Field;
66

7-
use Ibexa\Contracts\Core\Repository\FieldType;
8-
use Netgen\IbexaFieldTypeEnhancedLink\FieldType\Type;
9-
use Netgen\IbexaFieldTypeEnhancedLink\FieldType\Value;
10-
use Symfony\Component\Form\DataTransformerInterface;
11-
12-
class FieldValueTransformer implements DataTransformerInterface
7+
class FieldValueTransformer extends \Ibexa\AdminUi\Form\DataTransformer\FieldType\FieldValueTransformer
138
{
14-
private FieldType $fieldType;
15-
16-
public function __construct(FieldType $fieldType)
17-
{
18-
$this->fieldType = $fieldType;
19-
}
20-
21-
public function transform($value): ?array
22-
{
23-
if (!$value instanceof Value) {
24-
return null;
25-
}
26-
27-
if ($value->isTypeExternal()) {
28-
return [
29-
'link_type' => Type::LINK_TYPE_EXTERNAL,
30-
'url' => $value->reference,
31-
'label_external' => $value->label,
32-
'target_external' => $value->target,
33-
];
34-
}
35-
36-
if ($value->isTypeInternal()) {
37-
return [
38-
'link_type' => Type::LINK_TYPE_INTERNAL,
39-
'id' => $value->reference,
40-
'label_internal' => $value->label,
41-
'target_internal' => $value->target,
42-
'suffix' => $value->suffix,
43-
];
44-
}
45-
46-
return null;
47-
}
48-
49-
public function reverseTransform($value): ?Value
50-
{
51-
if ($value['link_type'] === Type::LINK_TYPE_INTERNAL) {
52-
return new Value(
53-
$value['id'],
54-
$value['label_internal'],
55-
$value['target_internal'],
56-
$value['suffix'] ?? null,
57-
);
58-
}
59-
60-
if ($value['link_type'] === Type::LINK_TYPE_EXTERNAL) {
61-
return new Value(
62-
$value['url'],
63-
$value['label_external'],
64-
$value['target_external'],
65-
);
66-
}
67-
68-
return $this->fieldType->getEmptyValue();
69-
}
709
}

0 commit comments

Comments
 (0)