Code Duplication    Length = 11-11 lines in 2 locations

code/Controller/AssetAdmin.php 2 locations

@@ 214-224 (lines=11) @@
211
        $file = Injector::inst()->create($fileClass);
212
213
        // check canCreate permissions
214
        if (!$file->canCreate(null, $data)) {
215
            $result = ['message' => [
216
                'type' => 'error',
217
                'value' => _t(
218
                    'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.CreatePermissionDenied',
219
                    'You do not have permission to add files'
220
                )
221
            ]];
222
            return (new HTTPResponse(json_encode($result), 403))
223
                ->addHeader('Content-Type', 'application/json');
224
        }
225
226
        $uploadResult = $upload->loadIntoFile($tmpFile, $file, $parentRecord ? $parentRecord->getFilename() : '/');
227
        if (!$uploadResult) {
@@ 227-237 (lines=11) @@
224
        }
225
226
        $uploadResult = $upload->loadIntoFile($tmpFile, $file, $parentRecord ? $parentRecord->getFilename() : '/');
227
        if (!$uploadResult) {
228
            $result = ['message' => [
229
                'type' => 'error',
230
                'value' => _t(
231
                    'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.LoadIntoFileFailed',
232
                    'Failed to load file'
233
                )
234
            ]];
235
            return (new HTTPResponse(json_encode($result), 400))
236
                ->addHeader('Content-Type', 'application/json');
237
        }
238
239
        $file->ParentID = $parentRecord ? $parentRecord->ID : 0;
240
        $file->write();