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 = array();
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 (array('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

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