agence-adeliom / easy-common-bundle
A Symfony bundle for EasyAdmin that provide basic entity traits and a enum helper
Installs: 21 908
Dependents: 13
Suggesters: 0
Security: 0
Stars: 3
Watchers: 0
Forks: 7
Open Issues: 0
Type:symfony-bundle
pkg:composer/agence-adeliom/easy-common-bundle
Requires
- php: >=8.2
- easycorp/easyadmin-bundle: ^3.4 || ^v4.0
- symfony/config: ^6.4 || ^7.0
- symfony/dependency-injection: ^6.4 || ^7.0
- symfony/http-kernel: ^6.4 || ^7.0
- symfony/serializer: ^6.4 || ^7.0
- 3.x-dev
- 3.0.1-alpha
- 3.0.0-alpha
- 2.x-dev
- 2.0.127
- 2.0.126
- 2.0.125
- 2.0.124
- 2.0.123
- 2.0.122
- 2.0.121
- 2.0.120
- 2.0.119
- 2.0.118
- 2.0.117
- 2.0.116
- 2.0.115
- 2.0.114
- 2.0.112
- 2.0.111
- 2.0.110
- 2.0.109
- 2.0.108
- 2.0.107
- 2.0.106
- 2.0.105
- 2.0.104
- 2.0.103
- 2.0.102
- 2.0.101
- 2.0.100
- 2.0.99
- 2.0.98
- 2.0.97
- 2.0.96
- 2.0.95
- 2.0.94
- 2.0.93
- 2.0.92
- 2.0.91
- 2.0.90
- 2.0.89
- 2.0.88
- 2.0.87
- 2.0.86
- 2.0.85
- 2.0.84
- 2.0.83
- 2.0.82
- 2.0.81
- 2.0.80
- 2.0.79
- 2.0.78
- 2.0.77
- 2.0.76
- 2.0.75
- 2.0.74
- 2.0.73
- 2.0.72
- 2.0.71
- 2.0.70
- 2.0.69
- 2.0.68
- 2.0.67
- 2.0.66
- 2.0.65
- 2.0.64
- 2.0.63
- 2.0.62
- 2.0.61
- 2.0.60
- 2.0.59
- 2.0.57
- 2.0.56
- 2.0.55
- 2.0.54
- 2.0.53
- 2.0.52
- 2.0.49
- 2.0.48
- 2.0.47
- 2.0.46
- 2.0.45
- 2.0.44
- 2.0.43
- 2.0.42
- 2.0.41
- 2.0.40
- 2.0.39
- 2.0.38
- 2.0.37
- 2.0.36
- 2.0.35
- 2.0.34
- 2.0.33
- 2.0.32
- 2.0.31
- 2.0.30
- 2.0.29
- 2.0.28
- 2.0.27
- 2.0.26
- 2.0.25
- 2.0.24
- 2.0.23
- 2.0.22
- 2.0.19
- 2.0.18
- 2.0.17
- 2.0.16
- 2.0.15
- 2.0.10
- 2.0.9
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 1.0.0
- dev-develop
- dev-main
This package is auto-updated.
Last update: 2025-10-29 20:17:26 UTC
README
Easy Common Bundle
Provide base utilities for Easyadmin.
Features
- A Enum polyfill for PHP 8 (< 8.1.0)
- Some Traits for entities
Versions
| Repository Branch | Version | Symfony Compatibility | PHP Compatibility | Status | 
|---|---|---|---|---|
| 3.x | 3.x | 6.4, and7.x | 8.2or higher | New features and bug fixes | 
| 2.x | 2.x | 5.4, and6.x | 8.0.2or higher | Bug fixes | 
| 1.x | 1.x | 4.4, and5.x | 7.2.5or higher | No longer maintained | 
Installation
Install with composer
composer require agence-adeliom/easy-common-bundle
Traits
Enum helper
Declaration
use Adeliom\EasyCommonBundle\Helper\Enum; /** * Action enum */ final class Action extends Enum { private const VIEW = 'view'; private const EDIT = 'edit'; }
Usage
$action = Action::VIEW(); // or with a dynamic key: $action = Action::$key(); // or with a dynamic value: $action = Action::from($value); // or $action = new Action($value);
As you can see, static methods are automatically implemented to provide quick access to an enum value.
One advantage over using class constants is to be able to use an enum as a parameter type:
function setAction(Action $action) { // ... }
Documentation
- __construct()The constructor checks that the value exist in the enum
- __toString()You can- echo $myValue, it will display the enum value (value of the constant)
- getValue()Returns the current value of the enum
- getKey()Returns the key of the current value on Enum
- equals()Tests whether enum instances are equal (returns- trueif enum values are equal,- falseotherwise)
Static methods:
- from()Creates an Enum instance, checking that the value exist in the enum
- toArray()method Returns all possible values as an array (constant name in key, constant value in value)
- keys()Returns the names (keys) of all constants in the Enum class
- values()Returns instances of the Enum class of all Enum constants (constant name in key, Enum instance in value)
- isValid()Check if tested value is valid on enum set
- isValidKey()Check if tested key is valid on enum set
- assertValidValue()Assert the value is valid on enum set, throwing exception otherwise
- search()Return key for searched value
Static methods
final class Action extends Enum { private const VIEW = 'view'; private const EDIT = 'edit'; } // Static method: $action = Action::VIEW(); $action = Action::EDIT();
Static method helpers are implemented using __callStatic().
If you care about IDE autocompletion, you can either implement the static methods yourself:
final class Action extends Enum { private const VIEW = 'view'; /** * @return Action */ public static function VIEW() { return new Action(self::VIEW); } }
or you can use phpdoc (this is supported in PhpStorm for example):
/** * @method static Action VIEW() * @method static Action EDIT() */ final class Action extends Enum { private const VIEW = 'view'; private const EDIT = 'edit'; }