artgris / easy-admin-commands-bundle
EasyAdminBundle config generator
Installs: 113
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 6
Type:symfony-bundle
Requires
Requires (Dev)
- dev-master
- 1.0.0
- dev-dependabot/composer/twig/twig-2.14.11
- dev-dependabot/composer/symfony/security-core-4.4.23
- dev-dependabot/composer/symfony/security-http-4.4.22
- dev-dependabot/composer/symfony/security-guard-4.4.23
- dev-dependabot/composer/symfony/http-kernel-4.4.13
- dev-dependabot/composer/symfony/http-foundation-4.4.7
- dev-feat-command
This package is auto-updated.
Last update: 2022-10-11 04:26:17 UTC
README
Installation
composer require artgris/easy-admin-commands-bundle
Configuration:
in config/packages
add artgris_easy_commands.yaml:
artgris_easy_admin_commands: dir: '%kernel.project_dir%/config/packages/easy_admin/entities/'
and create a new config/packages/easy_admin/ directory
Generate easyadmin conf
php bin/console artgris:easyadmin:export
Edit easyadmin yaml
# config/packages/easy_admin.yaml imports: - { resource: easy_admin/ }
Basic Configuration
Example Entity :
<?php namespace App\Entity; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; /** * @ORM\Entity() */ class Example { /** * @ORM\Id() * @ORM\GeneratedValue() * @ORM\Column(type="integer") */ private $id; /** * @var string * @ORM\Column(type="string", length=255) * @Assert\Length(max=255) * @Assert\NotBlank */ private $name; /** * @var string * @ORM\Column(type="text", nullable=true) */ private $description; /** * @var \DateTime * @ORM\Column(type="date") * @Assert\Date() * @Assert\NotBlank() */ private $date; ...
artgris_easy_admin_commands: dir: '%kernel.project_dir%/config/packages/easy_admin/entities/' namespaces: - 'App\Entity' types: text: type_options: attr: {class: 'tinymce'} date: type: date type_options: attr: class: 'flatpickr' autocomplete: 'off' widget: 'single_text' format: 'dd/MM/yyyy' list: excluded: - id form: excluded: - id
php bin/console artgris:easyadmin:export
generated configuration:
# entities/example.yaml : easy_admin: entities: example: class: App\Entity\Example list: fields: - name - description - date form: fields: - name - { property: description, type_options: { attr: { class: tinymce } } } - { property: date, type: date, type_options: { attr: { class: flatpickr, autocomplete: 'off' }, widget: single_text, format: dd/MM/yyyy } } edit: fields: - name - { property: description, type_options: { attr: { class: tinymce } } } - { property: date, type: date, type_options: { attr: { class: flatpickr, autocomplete: 'off' }, widget: single_text, format: dd/MM/yyyy } } new: fields: - name - { property: description, type_options: { attr: { class: tinymce } } } - { property: date, type: date, type_options: { attr: { class: flatpickr, autocomplete: 'off' }, widget: single_text, format: dd/MM/yyyy } }
Exhaustive configuration
artgris_easy_admin_commands: dir: '%kernel.project_dir%/config/packages/easy_admin/entities/' namespaces: - 'App\Entity' entities: included: - 'App\Entity\Example' excluded: - 'App\Entity\User' types: text: type_options: attr: {class: 'tinymce'} image: type: image base_path: '%app.path.product_images%' regex: ^image*: image ... list: included: - name - ... excluded: - id - ... position: - name - ... sort: - ['createdAt', 'desc'] - ... form: included: - name - ... excluded: - id - ... position: - name - ...
dir : The folder in which the configuration is generated
namespaces : Entity search namespaces
entities
- included : only includes these entities
- excluded : exclude the following entities
types : If a doctrine type metadata type is found, the generator will use the associated configuration
regex : forces the type of an entity field according to its name and a regex
list
- included : only includes these fields in the list (if they are present in the entity)
- excluded : exclude the following fields from the list (if they are present in the entity)
- position : position of fields in the list (if they are present in the entity)
- sort : sort by following fields (first found in list)
form : same as list
Export a specific Entity
⚠️ this command override the configuration parameter 'entities' ('included/excluded')
php bin/console artgris:easyadmin:export 'App\Entity\Example'
or
php bin/console artgris:easyadmin:export App\\Entity\\Example