Code Duplication    Length = 38-38 lines in 2 locations

Controller/AdminBlockController.php 1 location

@@ 107-144 (lines=38) @@
104
    /**
105
     * {@inheritdoc}
106
     */
107
    protected function redirectTo($object)
108
    {
109
        $request = $this->getRequest();
110
111
        $url = $backToNodeList = false;
112
        $instanceAdmin = $this->admin->getConfigurationPool()->getInstance('alpixel_cms.admin.block');
113
114
        if (null !== $request->get('btn_update_and_list') || null !== $request->get('btn_create_and_list')) {
115
            $backToNodeList = true;
116
        }
117
118
        if (null !== $request->get('btn_create_and_create')) {
119
            $params = [];
120
            if ($this->admin->hasActiveSubClass()) {
121
                $params['subclass'] = $request->get('subclass');
122
            }
123
            $url = $this->admin->generateUrl('create', $params);
124
        }
125
126
        if ($this->getRestMethod() === 'DELETE') {
127
            $backToNodeList = true;
128
        }
129
130
        if (!$url) {
131
            foreach (['edit', 'show'] as $route) {
132
                if ($this->admin->hasRoute($route) && $this->admin->isGranted(strtoupper($route), $object)) {
133
                    $url = $this->admin->generateObjectUrl($route, $object);
134
                    break;
135
                }
136
            }
137
        }
138
139
        if ($backToNodeList || !$url) {
140
            $url = $instanceAdmin->generateUrl('list');
141
        }
142
143
        return new RedirectResponse($url);
144
    }
145
}
146

Controller/AdminNodeController.php 1 location

@@ 84-121 (lines=38) @@
81
    /**
82
     * {@inheritdoc}
83
     */
84
    protected function redirectTo($object)
85
    {
86
        $request = $this->getRequest();
87
88
        $url = $backToNodeList = false;
89
        $instanceAdmin = $this->admin->getConfigurationPool()->getInstance('alpixel_cms.admin.node');
90
91
        if (null !== $request->get('btn_update_and_list') || null !== $request->get('btn_create_and_list')) {
92
            $backToNodeList = true;
93
        }
94
95
        if (null !== $request->get('btn_create_and_create')) {
96
            $params = [];
97
            if ($this->admin->hasActiveSubClass()) {
98
                $params['subclass'] = $request->get('subclass');
99
            }
100
            $url = $this->admin->generateUrl('create', $params);
101
        }
102
103
        if ($this->getRestMethod() === 'DELETE') {
104
            $backToNodeList = true;
105
        }
106
107
        if (!$url) {
108
            foreach (['edit', 'show'] as $route) {
109
                if ($this->admin->hasRoute($route) && $this->admin->isGranted(strtoupper($route), $object)) {
110
                    $url = $this->admin->generateObjectUrl($route, $object);
111
                    break;
112
                }
113
            }
114
        }
115
116
        if ($backToNodeList || !$url) {
117
            $url = $instanceAdmin->generateUrl('list');
118
        }
119
120
        return new RedirectResponse($url);
121
    }
122
}
123