\Vegas\DIScaffolding

Class Scaffolding

Usage class MyController extends Controller\Crud {

 protected $formName = 'My\Forms\My';    // default form used by CRUD
 protected $modelName = 'My\Models\My';  // default model used by CRUD

 public function initialize()
 {
     parent::initialize();
     // we can also add this event in the Module.php to the dispatcher
     $this->dispatcher->getEventsManager()->attach(
         Controller\Crud\Events::AFTER_CREATE, function() {
             $this->response->redirect('user-admin/index');
         }
     );
     // attach more events
 }
 // other actions

}

Summary

Methods
Properties
Constants
__construct()
getRecord()
getForm()
setForm()
setFormName()
setModelName()
doRead()
doCreate()
doUpdate()
doDelete()
getAdapter()
No public properties found
No constants found
No protected methods found
$di
$record
$form
$adapter
$modelName
$formName
N/A
No private methods found
No private properties found
N/A

Properties

$di

$di : 

Dependency injector

Type

$record

$record : 

Record object

Type

$form

$form : 

Form object

Type

$modelName

$modelName : string

Model class name

Type

string

$formName

$formName : string

Form class name

Type

string

Methods

getRecord()

getRecord() : mixed

Returns record object If record is empty, new record will be created

Returns

mixed

getForm()

getForm( $entity) : mixed

Creates and returns form instance

Parameters

$entity

Returns

mixed

setForm()

setForm( $form)

Sets form instance

Parameters

$form

setFormName()

setFormName( $name) : mixed

Sets form name

Parameters

$name

Returns

mixed

setModelName()

setModelName( $name) : mixed

Sets model name

Parameters

$name

Returns

mixed

doRead()

doRead( $id) : mixed

Retrieves record by its ID

Parameters

$id

Returns

mixed

doCreate()

doCreate(array $values) : mixed

Creates new record

Parameters

array $values

Returns

mixed

doUpdate()

doUpdate( $id, array $values) : mixed

Updates existing record by its ID

Parameters

$id
array $values

Returns

mixed

doDelete()

doDelete( $id) : mixed

Deletes existing record by its ID

Parameters

$id

Returns

mixed