Skip to content

Latest commit

 

History

History
45 lines (32 loc) · 2.53 KB

models.md

File metadata and controls

45 lines (32 loc) · 2.53 KB

Models

Models are the backbone of the CRUD operation and define everything the crud manager needs to know in order to handle the entire process.

The only requirement of a model is that it implements SpiffyCrud\Model\ModelInterface but typically you should extend the provided SpiffyCrud\Model\AbstractModel.

The crud manager will throw an exception if you try to register or retrieve any models that are invalid.

Model Properties

$displayName (optional)

Custom name to use for display purposes.

$adapterName (optional)

The name of the service from the adapter manager to use for persistence. Falls back to the default_adapter if not set.

$hydratorName (optional)

The name of the service from the hydrator manager to use for hydration. Falls back to the default_hydrator if not set.

$entityClass (required)

The class name of the entity for CRUD operations.

$formSpec (optional)

The spec to use for creating the custom form for this entity. If no form is present then forms will be built using the annotation form builder from the model $entityClass). Arrays are passed to the form factory and strings are retrieved from the form element manager, forms abstract service factory (if registered), and finaly instantiated directly if the class exists.

$viewOptions (optional)

These are passed directly to the view helper and vary based on which view helper you are using. By default, SpiffyCrud uses spiffy-datatables for renderering the view.

$adapterOptions (optional)

These are passed directly to the adapter for each crud operation and typically contain things like the table name or additional metadata. By default, SpiffyCrud uses DoctrineORMModule for persistence so no additional metadata is required.