-
-
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.
minor #4024 Replaced some magic strings by constants (javiereguiluz)
This PR was merged into the 3.0.x-dev branch. Discussion ---------- Replaced some magic strings by constants We use DTOs, objects and constants for all the config stuff ... but the arguments of some functions and the keys of some arrays were still using "magic strings". Let's fix that. In PHP 8.1 we'll probably have Enums, but for now, let's use very simple classes with public constants. Please note that I don't want to update the docs about this. Let's keep using "magic strings" in docs for now, specially because using constants in Twig is super-verbose, so I don't want readers to think that they should use these long and boring constants in their templates. #SymfonyHackday Commits ------- 0333d87 Replaced some magic strings by constants
- Loading branch information
Showing
27 changed files
with
179 additions
and
79 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace EasyCorp\Bundle\EasyAdminBundle\Config\Option; | ||
|
||
/** | ||
* @author Javier Eguiluz <javier.eguiluz@gmail.com> | ||
*/ | ||
final class EA | ||
{ | ||
public const CONTEXT_NAME = 'eaContext'; | ||
public const MENU_INDEX = 'menuIndex'; | ||
public const SUBMENU_INDEX = 'submenuIndex'; | ||
public const QUERY = 'query'; | ||
public const FILTERS = 'filters'; | ||
public const SORT = 'sort'; | ||
public const REFERRER = 'referrer'; | ||
public const DASHBOARD_CONTROLLER_FQCN = 'dashboardControllerFqcn'; | ||
public const CRUD_CONTROLLER_FQCN = 'crudControllerFqcn'; | ||
public const CRUD_ACTION = 'crudAction'; | ||
public const CRUD_ID = 'crudId'; | ||
public const ENTITY_FQCN = 'entityFqcn'; | ||
public const ENTITY_ID = 'entityId'; | ||
} |
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,14 @@ | ||
<?php | ||
|
||
namespace EasyCorp\Bundle\EasyAdminBundle\Config\Option; | ||
|
||
/** | ||
* @author Javier Eguiluz <javier.eguiluz@gmail.com> | ||
*/ | ||
final class Size | ||
{ | ||
public const SM = 'sm'; | ||
public const MD = 'md'; | ||
public const LG = 'lg'; | ||
public const XL = 'xl'; | ||
} |
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,12 @@ | ||
<?php | ||
|
||
namespace EasyCorp\Bundle\EasyAdminBundle\Config\Option; | ||
|
||
/** | ||
* @author Javier Eguiluz <javier.eguiluz@gmail.com> | ||
*/ | ||
final class SortOrder | ||
{ | ||
public const ASC = 'ASC'; | ||
This comment has been minimized.
Sorry, something went wrong. |
||
public const DESC = 'DESC'; | ||
} |
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,13 @@ | ||
<?php | ||
|
||
namespace EasyCorp\Bundle\EasyAdminBundle\Config\Option; | ||
|
||
/** | ||
* @author Javier Eguiluz <javier.eguiluz@gmail.com> | ||
*/ | ||
final class TextAlign | ||
{ | ||
public const LEFT = 'left'; | ||
public const CENTER = 'center'; | ||
public const RIGHT = 'right'; | ||
} |
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,12 @@ | ||
<?php | ||
|
||
namespace EasyCorp\Bundle\EasyAdminBundle\Config\Option; | ||
|
||
/** | ||
* @author Javier Eguiluz <javier.eguiluz@gmail.com> | ||
*/ | ||
final class TextDirection | ||
{ | ||
public const LTR = 'ltr'; | ||
public const RTL = 'rtl'; | ||
} |
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
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
Oops, something went wrong.
I now about PHP constants SORT_ASC and SORT_DESC. Why not use them?
https://www.php.net/manual/en/array.constants.php