Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
javiereguiluz committed Oct 22, 2023
1 parent b704f5e commit 47708a4
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/Router/AdminUrlGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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)) {
Expand All @@ -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) {
Expand All @@ -104,6 +128,9 @@ public function setAll(array $routeParameters): AdminUrlGeneratorInterface
return $this;
}

/**
* @return AdminUrlGenerator
*/
public function unset(string $paramName): AdminUrlGeneratorInterface
{
if (false === $this->isInitialized) {
Expand All @@ -115,6 +142,9 @@ public function unset(string $paramName): AdminUrlGeneratorInterface
return $this;
}

/**
* @return AdminUrlGenerator
*/
public function unsetAll(): AdminUrlGeneratorInterface
{
if (false === $this->isInitialized) {
Expand All @@ -126,6 +156,9 @@ public function unsetAll(): AdminUrlGeneratorInterface
return $this;
}

/**
* @return AdminUrlGenerator
*/
public function unsetAllExcept(string ...$namesOfParamsToKeep): AdminUrlGeneratorInterface
{
if (false === $this->isInitialized) {
Expand All @@ -137,6 +170,9 @@ public function unsetAllExcept(string ...$namesOfParamsToKeep): AdminUrlGenerato
return $this;
}

/**
* @return AdminUrlGenerator
*/
public function includeReferrer(): AdminUrlGeneratorInterface
{
if (false === $this->isInitialized) {
Expand All @@ -148,6 +184,9 @@ public function includeReferrer(): AdminUrlGeneratorInterface
return $this;
}

/**
* @return AdminUrlGenerator
*/
public function removeReferrer(): AdminUrlGeneratorInterface
{
if (false === $this->isInitialized) {
Expand All @@ -159,6 +198,9 @@ public function removeReferrer(): AdminUrlGeneratorInterface
return $this;
}

/**
* @return AdminUrlGenerator
*/
public function setReferrer(string $referrer): AdminUrlGeneratorInterface
{
if (false === $this->isInitialized) {
Expand All @@ -171,6 +213,9 @@ public function setReferrer(string $referrer): AdminUrlGeneratorInterface
return $this;
}

/**
* @return AdminUrlGenerator
*/
public function addSignature(bool $addSignature = true): AdminUrlGeneratorInterface
{
trigger_deprecation(
Expand Down

0 comments on commit 47708a4

Please sign in to comment.