Rocket Annotations
Since version 4.0 of rocket, business objects can be configured for Rocket with annotations. The following article tells you how.
Class Annotations
The following annotations must be placed right before the definition of the class.
EiType
A business objects must be attributed as an EiType, if you want to manage it in Rocket! With the EiType you can configure how the Type is labeled. You can also define, how the identity string is build, by setting the identityStringPatern
. You can also set an icon
. All icons of Font Awesome version 5 are available.
#[EiType(label: 'Plan', pluralLabel: 'Plans', identityStringPattern:'{name} [{id}'], icon: 'fas fa-icon')]
EiMenuItem
With EiMenuItem an EiType is shown in the menue of Rocket. The name is the name
of the navigation item. groupName
is the name of the group where the navigation item is displayed. orderIndex
defines the position where the menu is displayed. EiTypes with a smaller orderIndex are displayed before others with a higher orderIndex.
#[EiMenuItem(name: 'User Settings', groupName: 'Settings')]
EiPreset
EiPreset is used to determine, what commands and what fields are displayed. If you do not have EiPreset on an EiType, the EiType can not be displayed, as no commands are defined. You can set fields to read You can also give names to fields.
With mode
you can give a general setting of the EiType. With readProps
you can tell which properties are read only. If you use a key=>value structure, you can also give a beautful name for the property. The same is also true for editProps
. Name all the properties there, that can be edited by Rocket. With excludeProps
you can exclude properties from being displayed.
#[EiPreset(mode: EiPresetMode::READ_PROPS_EDIT_CMDS, readProps: ['prettyDiscountMonthlyAmount' => 'Rabatt (monatlich)', 'prettyDiscountYearlyAmount' => 'Rabatt (jährlich)'], editProps: ['code', 'subPlan', 'multiple', 'discountYearlyAmount', 'discountMonthlyAmount', 'subCurrency'], excludeProps: ['id', 'owner'])]
EiDisplayScheme
With EiDisplayScheme you can tell Rocket, in what order the properties are displayed. There are several attributes: compact
is when this EiType is displayed in compact form. The most common compact form is the list of entities. bulky
is the general display type of one entity. There are subtypes as compactDetail
, compactAdd
, compactEdit
and bulkyDetail
, bulkyAdd
and bulkyEdit
.
#[EiDisplayScheme(compact: ['code', 'prettyDiscountMonthlyAmount', 'prettyDiscountYearlyAmount', 'redeemedBySubOrganisations', 'consumed'], compactDetail: ['code', 'currency', 'redeemedBySubOrganisations', 'consumed'], bulkyAdd: ['code', 'subPlan', 'multiple', 'discountYearlyAmount', 'discountMonthlyAmount', 'subCurrency'])]
EiDefaultSort
EiDefaultSort let's you define the default sort of your entities. Use the name of the property and the order direction in UPPERCASE in key value pairs. You can add more than one order direction into your array!
#[EiDefaultSort(['date' => 'DESC'])]
EiCmdEdit
You can add the edit command with this annotation.
#[EiCmdEdit]
EiModCallback
Can be used to add individual commands, controller, forms... etc.
Property Annotations
The following annotations can be placed right before a property of an EiType.
EiLabel
You can set a label on a propertiy with this annotation. Please note, that this label is stronger than the one that you set on EiPreset.readProps or EiPreset.editProps.
#[EiLabel('Zahlungen')]
EiProp*
There are many EiProp* classes that let you annotate properties of a certain type:
- EiPropString
- EiPropDecimal
- EiPropBool
- EiPropEnum
- EiPropOneToManyEmbedded
- EiPropOneToOneEmbedded
- EiPropOneToOneIntegrated
- EiPropOnlineStatus
- EiPropOrder
- EiPropPathPart
The common attributes that most of these EiProps share are:
-
constant
: the value does not change -
readOnly
: the value can not be edited -
mandatory
: the value must be given
In the following, only other attributes are explained
EiPropString
The with the multiline attribute, you can tell Rocket to display a textarea field instead of a normal text input field:
#[EiPropString(multiline: true)]
EiPropDecimal
With this annotation you can tell Rocket, that the input is a decimal number. You can decide on the numbers of decimal places with the attribute decimalPlaces
#[EiPropDecimal(decimalPlaces: 2)]
EiPropCke
This annotation is meant to annotate a Textfield with WYSIWYG properties. There are three differend mode: normal, simple and advanced. You find them on CkeMode. You can also assign a CSS with cssConfig and one or more add linkProviders.
#[EiPropCke(mode: CkeMode::NORMAL, cssConfig: TmplCkeCssConfig::class, linkProviders: [PageCkeLinkProvider::class], mandatory: true)]