Actions for the Admin need to implement the following interaface:
namespace Admin\Core\Actions;
interface ActionInterface {
/**
* Function to Check if this Requested Action is supported
* @author Marc Neuhaus <mneuhaus@famelo.com>
* */
public function canHandle($being, $action = null, $id = false);
/**
* The Name of this Action
* @author Marc Neuhaus <mneuhaus@famelo.com>
* */
public function __toString();
/**
* @param string $being
* @param array $ids
* @author Marc Neuhaus <mneuhaus@famelo.com>
* */
public function execute($being, $ids = null);
}
Description of the functions
Parameters: |
|
---|
Parameters: |
|
---|
The Delete action needs $ids to delete, so it returns true if there are ids to receive:
class DeleteAction extends \Admin\Core\Actions\AbstractAction {
public function canHandle($being, $action = null, $id = false) {
return $id;
}
}
The Update action needs $ids to update, but can’t handle bulk actions:
class UpdateAction extends \Admin\Core\Actions\AbstractAction {
public function canHandle($being, $action = null, $id = false) {
switch($action) {
case "bulk":
return false;
default:
return $id;
}
}
}
The function execute behaves exactly like a regular controllerAction. The following variables are defined in the ActionClass: