-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH #2870: Launch the LTI tool if it's the only one
- Loading branch information
Showing
4 changed files
with
138 additions
and
6 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
sourcecode/hub/app/Http/Middleware/LaunchCreateIfSingleTool.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Http\Middleware; | ||
|
||
use App\Models\LtiTool; | ||
use Closure; | ||
use Illuminate\Http\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
/** | ||
* Launch the tool if it's the only tool, and it does not have any non-admin extras | ||
*/ | ||
final readonly class LaunchCreateIfSingleTool | ||
{ | ||
public function handle(Request $request, Closure $next): Response | ||
{ | ||
if (LtiTool::count() === 1) { | ||
$ltiTool = LtiTool::first(); | ||
if ($ltiTool->extras()->forAdmins(false)->count() === 0) { | ||
return redirect( | ||
route('content.launch-creator', $ltiTool) | ||
); | ||
} | ||
} | ||
|
||
return $next($request); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters