Code Duplication    Length = 11-11 lines in 2 locations

code/Controller/AssetAdmin.php 2 locations

@@ 379-389 (lines=11) @@
376
        $file = Injector::inst()->create($fileClass);
377
378
        // check canCreate permissions
379
        if (!$file->canCreate(null, $data)) {
380
            $result = ['message' => [
381
                'type' => 'error',
382
                'value' => _t(
383
                    'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.CreatePermissionDenied',
384
                    'You do not have permission to add files'
385
                )
386
            ]];
387
            return (new HTTPResponse(json_encode($result), 403))
388
                ->addHeader('Content-Type', 'application/json');
389
        }
390
391
        $uploadResult = $upload->loadIntoFile($tmpFile, $file, $parentRecord ? $parentRecord->getFilename() : '/');
392
        if (!$uploadResult) {
@@ 392-402 (lines=11) @@
389
        }
390
391
        $uploadResult = $upload->loadIntoFile($tmpFile, $file, $parentRecord ? $parentRecord->getFilename() : '/');
392
        if (!$uploadResult) {
393
            $result = ['message' => [
394
                'type' => 'error',
395
                'value' => _t(
396
                    'SilverStripe\\AssetAdmin\\Controller\\AssetAdmin.LoadIntoFileFailed',
397
                    'Failed to load file'
398
                )
399
            ]];
400
            return (new HTTPResponse(json_encode($result), 400))
401
                ->addHeader('Content-Type', 'application/json');
402
        }
403
404
        $file->ParentID = $parentRecord ? $parentRecord->ID : 0;
405
        $file->write();