Download the PHP package neimheadh/sonata-annotation-bundle without Composer
On this page you can find all versions of the php package neimheadh/sonata-annotation-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download neimheadh/sonata-annotation-bundle
More information about neimheadh/sonata-annotation-bundle
Files in neimheadh/sonata-annotation-bundle
Package sonata-annotation-bundle
Short Description Symfony Bundle that adds annotations for Sonata Admin.
License MIT
Homepage https://github.com/kunicmarko20/SonataAnnotationBundle
Informations about the package sonata-annotation-bundle
Sonata Annotation Bundle
Adds Annotations for Sonata Admin.
The point is to reduce noise, having lots of admin classes with just mappings that don't do anything else should be avoided. Add annotations to your models and you are done. If you need something that is not covered by this bundle, create admin class instead.
This bundle is a fork of the archived KunicMarko\SonataAnnotationBundle.
Documentation
- Installation
- Configuration
- How to use
- Annotations
- Admin
- Access
- AddChild
- FormField
- ShowField
- ShowAssociationField
- ListField
- ListAssociationField
- DatagridField
- DatagridAssociationField
- ExportField
- ExportAssociationField
- ExportFormats
- AddRoute
- RemoveRoute
- ActionButton
- DashboardAction
- ListAction
- DatagridValues
- Extending The Admin
Installation
1. Add dependency with composer
2. Register the bundle in your Kernel
Configuration
By default we scan all files in your src
directory, if you save your entities somewhere
else you can change the directory:
How to use
Instead of creating class for Admin it is enough to just add annotation to your entity.
Clear cache:
And you will see Admin appear in your sidebar.
Note that if you can also use class attributes:
Annotations
Admin
Access
If you are using role handler as described here you can add permission per role with this annotation.
This annotation can be used without Admin annotation present. If you have an admin class for your entity you can still use this annotation.
AddChild
You can read more about this here.
This annotation can be used without Admin annotation present. If you have an admin class for your entity you can still use this annotation.
FormField
You can specify action option that would allow you to have different fields or have different configuration for the same field for create and edit action. If not set, field will be used for create and edit. Besides that, you are able to set the position of the field. Position 1 would be the first field to render and higher numbers after. If field doesn't have position, it will be rendered after all fields with position.
Form fields can also be added on class level through formFields
class Admin
annotation property:
By default, if any field configured, all field will be available.
ShowField
You are able to set the position of the field. Position 1 would be the first field to render and higher numbers after. If field doesn't have position, it will be rendered after all fields with position.
Show fields can also be added on class level through showFields
class Admin
annotation property:
By default, if any field configured, all field will be available.
ShowAssociationField
You are able to set the position of the field. Position 1 would be the first field to render and higher numbers after. If field doesn't have position, it will be rendered after all fields with position.
ListField
You are able to set the position of the field. Position 1 would be the first field to render and higher numbers after. If field doesn't have position, it will be rendered after all fields with position.
List fields can also be added on class level through listFields
class Admin
annotation property:
By default, if any field configured, all field will be available.
ListAssociationField
You are able to set the position of the field. Position 1 would be the first field to render and higher numbers after. If field doesn't have position, it will be rendered after all fields with position.
DatagridField
You are able to set the position of the field. Position 1 would be the first field to render and higher numbers after. If field doesn't have position, it will be rendered after all fields with position.
List fields can also be added on class level through datagridFields
class Admin
annotation property:
By default, if any field configured, all field will be available.
DatagridAssociationField
You are able to set the position of the field. Position 1 would be the first field to render and higher numbers after. If field doesn't have position, it will be rendered after all fields with position.
ExportField
You can add annotation to fields/method that you want to export, also you can add label for the field, if left blank field name will be used as label.
By default, if any field configured, all field will be available.
ExportAssociationField
ExportFormats
You can customize the export formats you want to allow, if this annotation is not present, all formats are shown.
AddRoute
Add custom routes to your admin class:
RemoveRoute
remove already existing routes:
ActionButton
This will add button next to your add button in a list view. Here you can find how the template should look like.
DashboardAction
This will add button to your dashboard block for this entity. Here you can find how the template should look like.
ListAction
DatagridValues
As explained here.
Extending The Admin
Sometimes you need to do something custom and this bundle can't help you with
that but you still want to use annotations for most of the other stuff. You can
extend our admin class Neimheadh\SonataAnnotationBundle\Admin\AnnotationAdmin
and overwrite the methods you want.
And then in your entity you just provide that class
All versions of sonata-annotation-bundle with dependencies
sonata-project/admin-bundle Version ^4.0
symfony/config Version ^5.4 || ^6.0
symfony/dependency-injection Version ^5.4 || ^6.0
symfony/finder Version ^5.4 || ^6.0
symfony/http-kernel Version ^5.4 || ^6.0
php Version ^8.0