Extracting logic to get the destination folder to method

parent cfde81aa
......@@ -44,10 +44,7 @@ class MoveMediaController extends Controller
public function __invoke(MoveMediaRequest $request)
{
$destination = $this->folder->findFolder($request->get('destinationFolder'));
if ($destination === null) {
$destination = $this->makeRootFolder();
}
$destination = $this->getDestinationFolder($request->get('destinationFolder'));
$failedMoves = 0;
foreach ($request->get('files') as $file) {
......@@ -80,4 +77,18 @@ class MoveMediaController extends Controller
'path' => config('asgard.media.config.files-path'),
]);
}
/**
* @param int $destinationFolderId
* @return File
*/
protected function getDestinationFolder($destinationFolderId) : File
{
$destination = $this->folder->findFolder($destinationFolderId);
if ($destination === null) {
$destination = $this->makeRootFolder();
}
return $destination;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment