Skip to content

Commit

Permalink
Merge pull request #422 from beyondcode/analysis-N4G9PL
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
mechelon authored Sep 20, 2024
2 parents 3d771ed + aa2b011 commit f36d692
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 19 deletions.
1 change: 0 additions & 1 deletion app/Client/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Ratchet\WebSocket\WsServer;
use React\EventLoop\Factory as LoopFactory;
use React\EventLoop\LoopInterface;
use Symfony\Component\Routing\Route;

class Factory
{
Expand Down
14 changes: 8 additions & 6 deletions app/Client/Http/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@ public function handle(Request $request, ConnectionInterface $httpConnection)
));
}

private function getJsFilePath() {
return "/files/build/internal-dashboard/assets/" . collect(scandir(app()->basePath() . "/public/build/internal-dashboard/assets/"))->filter(function($file) {
return str($file)->startsWith("index-") && str($file)->endsWith(".js");
private function getJsFilePath()
{
return '/files/build/internal-dashboard/assets/'.collect(scandir(app()->basePath().'/public/build/internal-dashboard/assets/'))->filter(function ($file) {
return str($file)->startsWith('index-') && str($file)->endsWith('.js');
})->first();
}

private function getCssFilePath() {
return "/files/build/internal-dashboard/assets/" . collect(scandir(app()->basePath() . "/public/build/internal-dashboard/assets/"))->filter(function($file) {
return str($file)->startsWith("index-") && str($file)->endsWith(".css");
private function getCssFilePath()
{
return '/files/build/internal-dashboard/assets/'.collect(scandir(app()->basePath().'/public/build/internal-dashboard/assets/'))->filter(function ($file) {
return str($file)->startsWith('index-') && str($file)->endsWith('.css');
})->first();
}
}
17 changes: 9 additions & 8 deletions app/Client/Http/Controllers/FileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,34 @@
namespace App\Client\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Ratchet\ConnectionInterface;
use GuzzleHttp\Psr7\Message;
use GuzzleHttp\Psr7\Response;
use Illuminate\Http\Request;
use Ratchet\ConnectionInterface;

class FileController extends Controller
{
public function handle(Request $request, ConnectionInterface $httpConnection)
{
$file = $request->get("path");
$file = $request->get('path');

$filePath = app()->basePath() . "/public/" . $file;
$filePath = app()->basePath().'/public/'.$file;

if(!file_exists($filePath)) {
if (! file_exists($filePath)) {
$httpConnection->send(Message::toString(new Response(
404,
['Content-Type' => 'text/html'],
"File not found"
'File not found'
)));

return;
}

$file = file_get_contents($filePath);
$contentType = mime_content_type($filePath);

if(str($filePath)->endsWith(".css")) {
$contentType = "text/css";
if (str($filePath)->endsWith('.css')) {
$contentType = 'text/css';
}

$httpConnection->send(Message::toString(new Response(
Expand Down
2 changes: 1 addition & 1 deletion app/Commands/ServerAwareCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected function lookupRemoteServers()
])->get(
// config('expose.server_endpoint', static::DEFAULT_SERVER_ENDPOINT)
'https://expose-platform.test/api/servers'
)->json();
)->json();
} catch (\Throwable $e) {
return [];
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Concerns/LoadsViews.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ protected function getView(?ConnectionInterface $connection, string $view, array
}
}

protected function getBlade(?ConnectionInterface $connection, string $view, array $data = []) {
protected function getBlade(?ConnectionInterface $connection, string $view, array $data = [])
{
return stream_for(view($view, $data)); // TODO: deprecated
}
}
5 changes: 3 additions & 2 deletions app/Http/RouteGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace App\Http;

use App\Client\Http\Controllers\FileController;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
use App\Client\Http\Controllers\FileController;

class RouteGenerator
{
Expand Down Expand Up @@ -56,7 +56,8 @@ public function addSymfonyRoute(string $name, Route $route)
$this->routes->add($name, $route);
}

public function addPublicFilesystem() {
public function addPublicFilesystem()
{
$this->routes->add('get-files', new Route(
'/files/{path}',
['_controller' => FileController::class],
Expand Down

0 comments on commit f36d692

Please sign in to comment.