Skip to content

Commit

Permalink
Added toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin-vdm committed Sep 5, 2024
1 parent be527e5 commit 64d4573
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Facades/Lodata.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
* @method static string getOdcUrl(Identifier|string $set) Get the Office Data Connection URL of the provided entity set
* @method static string getPbidsUrl() Get the PowerBI discovery URL of this service
* @method static string getOpenApiUrl() Get the OpenAPI specification document URL of this service
* @method static void ignoreRoutes() Disable the automatic registration of the base routes
* @method static bool shouldIgnoreRoutes() Determine if routes should be ignored
* @package Flat3\Lodata\Facades
*/
class Lodata extends Facade
Expand Down
24 changes: 24 additions & 0 deletions src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ class Model implements AnnotationInterface
*/
protected $entityContainer;

/**
* Determine if routes should be ignored
* @var true
*/
protected $registersRoutes;

public function __construct()
{
$this->model = new ObjectArray();
Expand Down Expand Up @@ -372,4 +378,22 @@ public function getOpenApiUrl(): string
{
return ServiceProvider::endpoint().'openapi.json';
}

/**
* Disable the automatic registration of the base routes
* @return void
*/
public function ignoreRoutes(): void
{
$this->registersRoutes = false;
}

/**
* Determine if routes should be ignored
* @return bool True if routes should be ignored, false otherwise.
*/
public function shouldIgnoreRoutes(): bool
{
return $this->registersRoutes;
}
}
5 changes: 4 additions & 1 deletion src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ public function boot()
Route::get("{$route}/_lodata/odata.pbids", [PBIDS::class, 'get']);
Route::get("{$route}/_lodata/{identifier}.odc", [ODCFF::class, 'get']);
Route::resource("{$route}/_lodata/monitor", Monitor::class);
Route::any("{$route}{path}", [OData::class, 'handle'])->where('path', '(.*)')->middleware($middleware);

if (Lodata::shouldIgnoreRoutes()) {
Route::any("{$route}{path}", [OData::class, 'handle'])->where('path', '(.*)')->middleware($middleware);
}
}
}

0 comments on commit 64d4573

Please sign in to comment.