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

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