Code Duplication    Length = 18-18 lines in 2 locations

src/Field/LinkField.php 1 location

@@ 49-66 (lines=18) @@
46
                '_self',
47
                '_blank',
48
            ])
49
            ->setNormalizer('route', function (Options $options, $value) use ($actionConfiguration) {
50
                // route or url should be defined
51
                if (!$value && !$options->offsetGet('url') && !$options->offsetGet('admin')) {
52
                    throw new InvalidOptionsException(
53
                        'You must set either an url or a route for the property'
54
                    );
55
                }
56
57
                if ($options->offsetGet('admin')) {
58
                    $value = RoutingLoader::generateRouteName(
59
                        $options->offsetGet('admin'),
60
                        $options->offsetGet('action'),
61
                        $actionConfiguration->getAdminConfiguration()->getParameter('routing_name_pattern')
62
                    );
63
                }
64
65
                return $value;
66
            })
67
            ->setNormalizer('admin', function (Options $options, $value) {
68
                // if a Admin is defined, an Action should be defined too
69
                if ($value && !$options->offsetGet('action')) {

src/Field/ActionCollectionField.php 1 location

@@ 141-158 (lines=18) @@
138
                '_self',
139
                '_blank',
140
            ])
141
            ->setNormalizer('route', function (Options $options, $value) use ($actionConfiguration) {
142
                // route or url should be defined
143
                if (!$value && !$options->offsetGet('url') && !$options->offsetGet('admin')) {
144
                    throw new InvalidOptionsException(
145
                        'You must set either an url or a route for the property'
146
                    );
147
                }
148
149
                if ($options->offsetGet('admin')) {
150
                    $value = RoutingLoader::generateRouteName(
151
                        $options->offsetGet('admin'),
152
                        $options->offsetGet('action'),
153
                        $actionConfiguration->getAdminConfiguration()->getParameter('routing_name_pattern')
154
                    );
155
                }
156
157
                return $value;
158
            })
159
            ->setNormalizer('admin', function (Options $options, $value) {
160
                // if a Admin is defined, an Action should be defined too
161
                if ($value && !$options->offsetGet('action')) {