-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b704f5e
commit 47708a4
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -10,6 +10,9 @@ | |
use EasyCorp\Bundle\EasyAdminBundle\Registry\DashboardControllerRegistry; | ||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | ||
|
||
/** | ||
* @author Javier Eguiluz <[email protected]> | ||
*/ | ||
final class AdminUrlGenerator implements AdminUrlGeneratorInterface | ||
{ | ||
private bool $isInitialized = false; | ||
|
@@ -29,13 +32,19 @@ public function __construct(AdminContextProvider $adminContextProvider, UrlGener | |
$this->dashboardControllerRegistry = $dashboardControllerRegistry; | ||
} | ||
|
||
/** | ||
* @return AdminUrlGenerator | ||
*/ | ||
public function setDashboard(string $dashboardControllerFqcn): AdminUrlGeneratorInterface | ||
{ | ||
$this->setRouteParameter(EA::DASHBOARD_CONTROLLER_FQCN, $dashboardControllerFqcn); | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return AdminUrlGenerator | ||
*/ | ||
public function setController(string $crudControllerFqcn): AdminUrlGeneratorInterface | ||
{ | ||
$this->setRouteParameter(EA::CRUD_CONTROLLER_FQCN, $crudControllerFqcn); | ||
|
@@ -45,6 +54,9 @@ public function setController(string $crudControllerFqcn): AdminUrlGeneratorInte | |
return $this; | ||
} | ||
|
||
/** | ||
* @return AdminUrlGenerator | ||
*/ | ||
public function setAction(string $action): AdminUrlGeneratorInterface | ||
{ | ||
$this->setRouteParameter(EA::CRUD_ACTION, $action); | ||
|
@@ -54,6 +66,9 @@ public function setAction(string $action): AdminUrlGeneratorInterface | |
return $this; | ||
} | ||
|
||
/** | ||
* @return AdminUrlGenerator | ||
*/ | ||
public function setRoute(string $routeName, array $routeParameters = []): AdminUrlGeneratorInterface | ||
{ | ||
$this->unsetAllExcept(EA::DASHBOARD_CONTROLLER_FQCN); | ||
|
@@ -63,6 +78,9 @@ public function setRoute(string $routeName, array $routeParameters = []): AdminU | |
return $this; | ||
} | ||
|
||
/** | ||
* @return AdminUrlGenerator | ||
*/ | ||
public function setEntityId($entityId): AdminUrlGeneratorInterface | ||
{ | ||
$this->setRouteParameter(EA::ENTITY_ID, $entityId); | ||
|
@@ -79,6 +97,9 @@ public function get(string $paramName): mixed | |
return $this->routeParameters[$paramName] ?? null; | ||
} | ||
|
||
/** | ||
* @return AdminUrlGenerator | ||
*/ | ||
public function set(string $paramName, $paramValue): AdminUrlGeneratorInterface | ||
{ | ||
if (\in_array($paramName, [EA::MENU_INDEX, EA::SUBMENU_INDEX], true)) { | ||
|
@@ -95,6 +116,9 @@ public function set(string $paramName, $paramValue): AdminUrlGeneratorInterface | |
return $this; | ||
} | ||
|
||
/** | ||
* @return AdminUrlGenerator | ||
*/ | ||
public function setAll(array $routeParameters): AdminUrlGeneratorInterface | ||
{ | ||
foreach ($routeParameters as $paramName => $paramValue) { | ||
|
@@ -104,6 +128,9 @@ public function setAll(array $routeParameters): AdminUrlGeneratorInterface | |
return $this; | ||
} | ||
|
||
/** | ||
* @return AdminUrlGenerator | ||
*/ | ||
public function unset(string $paramName): AdminUrlGeneratorInterface | ||
{ | ||
if (false === $this->isInitialized) { | ||
|
@@ -115,6 +142,9 @@ public function unset(string $paramName): AdminUrlGeneratorInterface | |
return $this; | ||
} | ||
|
||
/** | ||
* @return AdminUrlGenerator | ||
*/ | ||
public function unsetAll(): AdminUrlGeneratorInterface | ||
{ | ||
if (false === $this->isInitialized) { | ||
|
@@ -126,6 +156,9 @@ public function unsetAll(): AdminUrlGeneratorInterface | |
return $this; | ||
} | ||
|
||
/** | ||
* @return AdminUrlGenerator | ||
*/ | ||
public function unsetAllExcept(string ...$namesOfParamsToKeep): AdminUrlGeneratorInterface | ||
{ | ||
if (false === $this->isInitialized) { | ||
|
@@ -137,6 +170,9 @@ public function unsetAllExcept(string ...$namesOfParamsToKeep): AdminUrlGenerato | |
return $this; | ||
} | ||
|
||
/** | ||
* @return AdminUrlGenerator | ||
*/ | ||
public function includeReferrer(): AdminUrlGeneratorInterface | ||
{ | ||
if (false === $this->isInitialized) { | ||
|
@@ -148,6 +184,9 @@ public function includeReferrer(): AdminUrlGeneratorInterface | |
return $this; | ||
} | ||
|
||
/** | ||
* @return AdminUrlGenerator | ||
*/ | ||
public function removeReferrer(): AdminUrlGeneratorInterface | ||
{ | ||
if (false === $this->isInitialized) { | ||
|
@@ -159,6 +198,9 @@ public function removeReferrer(): AdminUrlGeneratorInterface | |
return $this; | ||
} | ||
|
||
/** | ||
* @return AdminUrlGenerator | ||
*/ | ||
public function setReferrer(string $referrer): AdminUrlGeneratorInterface | ||
{ | ||
if (false === $this->isInitialized) { | ||
|
@@ -171,6 +213,9 @@ public function setReferrer(string $referrer): AdminUrlGeneratorInterface | |
return $this; | ||
} | ||
|
||
/** | ||
* @return AdminUrlGenerator | ||
*/ | ||
public function addSignature(bool $addSignature = true): AdminUrlGeneratorInterface | ||
{ | ||
trigger_deprecation( | ||
|