Code Duplication    Length = 11-11 lines in 2 locations

code/Controller/AssetAdmin.php 2 locations

@@ 422-432 (lines=11) @@
419
        $file = Injector::inst()->create($fileClass);
420
421
        // check canCreate permissions
422
        if (!$file->canCreate(null, $data)) {
423
            $result = ['message' => [
424
                'type' => 'error',
425
                'value' => _t(
426
                    'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.CreatePermissionDenied',
427
                    'You do not have permission to add files'
428
                )
429
            ]];
430
            return (new HTTPResponse(json_encode($result), 403))
431
                ->addHeader('Content-Type', 'application/json');
432
        }
433
434
        $uploadResult = $upload->loadIntoFile($tmpFile, $file, $parentRecord ? $parentRecord->getFilename() : '/');
435
        if (!$uploadResult) {
@@ 435-445 (lines=11) @@
432
        }
433
434
        $uploadResult = $upload->loadIntoFile($tmpFile, $file, $parentRecord ? $parentRecord->getFilename() : '/');
435
        if (!$uploadResult) {
436
            $result = ['message' => [
437
                'type' => 'error',
438
                'value' => _t(
439
                    'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.LoadIntoFileFailed',
440
                    'Failed to load file'
441
                )
442
            ]];
443
            return (new HTTPResponse(json_encode($result), 400))
444
                ->addHeader('Content-Type', 'application/json');
445
        }
446
447
        $file->ParentID = $parentRecord ? $parentRecord->ID : 0;
448
        $file->write();