Code Duplication    Length = 18-18 lines in 2 locations

src/Field/ActionCollectionField.php 1 location

@@ 112-129 (lines=18) @@
109
                '_self',
110
                '_blank',
111
            ])
112
            ->setNormalizer('route', function (Options $options, $value) use ($actionConfiguration) {
113
                // route or url should be defined
114
                if (!$value && !$options->offsetGet('url') && !$options->offsetGet('admin')) {
115
                    throw new InvalidOptionsException(
116
                        'You must set either an url or a route for the property'
117
                    );
118
                }
119
120
                if ($options->offsetGet('admin')) {
121
                    $value = RoutingLoader::generateRouteName(
122
                        $options->offsetGet('admin'),
123
                        $options->offsetGet('action'),
124
                        $actionConfiguration->getAdminConfiguration()->getParameter('routing_name_pattern')
125
                    );
126
                }
127
128
                return $value;
129
            })
130
            ->setNormalizer('admin', function (Options $options, $value) {
131
                // if a Admin is defined, an Action should be defined too
132
                if ($value && !$options->offsetGet('action')) {

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')) {