PHP Класс Crud\Controller\Component\CrudComponent

Scaffolding on steroids! :) Licensed under The MIT License For full copyright and license information, please see the LICENSE.txt
Наследование: extends Cake\Controller\Component
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$_action string The current controller action.
$_actionInstances array List of crud actions.
$_controller Cake\Controller\Controller Reference to the current controller.
$_defaultConfig array eventPrefix All emitted events will be prefixed with this property value. actions contains an array of controller methods this component should offer implementation for. Each action maps to a CrudAction class. $controllerAction => $crudActionClass. Example: array('admin_index' => 'Crud.Index') By default no actions are enabled. listeners List of internal-name => ${plugin}.${class} listeners that will be bound automatically in Crud. By default the related model event are bound. Events will always assume to be in the Controller/Event folder. eventLogging boolean to determine whether the class should log triggered events.
$_eventLog array A flat array of the events triggered.
$_eventManager Cake\Event\EventManager Reference to the current event manager.
$_listenerInstances array List of listener objects attached to Crud.
$_modelName string Cached property for Controller::$modelClass. This is the model name of the current model.
$_request Cake\Network\Request Reference to the current request.

Открытые методы

Метод Описание
__construct ( Cake\Controller\ComponentRegistry $collection, array $config = [] ) Constructor
action ( string | null $name = null ) : BaseAction Get a CrudAction object by action name.
addListener ( string $name, string $className = null, array $config = [] ) : void Add a new listener to Crud
beforeFilter ( Cake\Event\Event $event ) : void Add self to list of components capable of dispatching an action.
controller ( ) : Controller Returns controller instance
defaults ( string $type, string | array $name, mixed $config = null ) : mixed Set or get defaults for listeners and actions.
disable ( string | array $actions ) : void Disable one or multiple CRUD actions.
enable ( string | array $actions ) : void Enable one or multiple CRUD actions.
entity ( array $data = [] ) : Cake\ORM\Entity Returns new entity
eventLog ( ) : array Returns an array of triggered events.
execute ( string $controllerAction = null, array $args = [] ) : Response Execute a Crud action
findMethod ( string | array $action, string | null $method = null ) : void Map a controller action to a Model::find($method).
getSubject ( array $additional = [] ) : Crud\Event\Subject Create a CakeEvent subject with the required properties.
isActionMapped ( string | null $action = null ) : boolean Check if a CRUD action has been mapped (whether it will be handled by CRUD component)
listener ( string $name ) : BaseListener Get a single event class.
logEvent ( string $eventName, array $data = [] ) : void Add a log entry for the event.
mapAction ( string $action, string | array $config = [], boolean $enable = true ) : void Map action to an internal request type.
normalizeArray ( array $array ) : array Normalize config array
on ( string | array $events, callback $callback, array $options = [] ) : void Attaches an event listener function to the controller for Crud Events.
removeListener ( string $name ) : boolean Remove a listener from Crud.
startup ( Cake\Event\Event $event ) : void Called after the Controller::beforeFilter() and before the controller action.
table ( ) : Table Returns controller's table instance.
trigger ( string $eventName, Crud\Event\Subject $data = null ) : Cake\Event\Event Triggers a Crud event by creating a new subject and filling it with $data if $data is an instance of CrudSubject it will be reused as the subject object for this event.
useModel ( string $modelName ) : void Sets the model class to be used during the action execution.
view ( string | array $action, string | null $view = null ) : void Map the view file to use for a controller action.
viewVar ( string | array $action, string | null $viewVar = null ) : void Change the viewVar name for one or multiple actions.

Защищенные методы

Метод Описание
_loadAction ( string $name ) : BaseAction Load a CrudAction instance.
_loadListener ( string $name ) : BaseListener Load a single event class attached to Crud.
_loadListeners ( ) : void Load all event classes attached to Crud.

Описание методов

__construct() публичный Метод

Constructor
public __construct ( Cake\Controller\ComponentRegistry $collection, array $config = [] )
$collection Cake\Controller\ComponentRegistry A ComponentCollection this component can use to lazy load its components.
$config array Array of configuration settings.

_loadAction() защищенный Метод

Load a CrudAction instance.
protected _loadAction ( string $name ) : BaseAction
$name string The controller action name.
Результат Crud\Action\BaseAction

_loadListener() защищенный Метод

Load a single event class attached to Crud.
protected _loadListener ( string $name ) : BaseListener
$name string Name
Результат Crud\Listener\BaseListener

_loadListeners() защищенный Метод

Load all event classes attached to Crud.
protected _loadListeners ( ) : void
Результат void

action() публичный Метод

Get a CrudAction object by action name.
public action ( string | null $name = null ) : BaseAction
$name string | null The controller action name.
Результат Crud\Action\BaseAction

addListener() публичный Метод

This will not load or initialize the listener, only lazy-load it. If $name is provided but no $class argument, the className will be derived from the $name. CakePHP Plugin.ClassName format for $name and $class is supported.
public addListener ( string $name, string $className = null, array $config = [] ) : void
$name string Name
$className string Normal CakePHP plugin-dot annotation supported.
$config array Any default settings for a listener.
Результат void

beforeFilter() публичный Метод

Add self to list of components capable of dispatching an action.
public beforeFilter ( Cake\Event\Event $event ) : void
$event Cake\Event\Event Event instance
Результат void

controller() публичный Метод

Returns controller instance
public controller ( ) : Controller
Результат Cake\Controller\Controller

defaults() публичный Метод

Set or get defaults for listeners and actions.
public defaults ( string $type, string | array $name, mixed $config = null ) : mixed
$type string Can be anything, but 'listeners' or 'actions' is currently only used.
$name string | array The name of the $type - e.g. 'api', 'relatedModels' or an array ('api', 'relatedModels'). If $name is an array, the $config will be applied to each entry in the $name array.
$config mixed If NULL, the defaults is returned, else the defaults are changed.
Результат mixed

disable() публичный Метод

Disable one or multiple CRUD actions.
public disable ( string | array $actions ) : void
$actions string | array The action to disable.
Результат void

enable() публичный Метод

Enable one or multiple CRUD actions.
public enable ( string | array $actions ) : void
$actions string | array The action to enable.
Результат void

entity() публичный Метод

Returns new entity
public entity ( array $data = [] ) : Cake\ORM\Entity
$data array Data
Результат Cake\ORM\Entity

eventLog() публичный Метод

Returns an array of triggered events.
public eventLog ( ) : array
Результат array

execute() публичный Метод

Execute a Crud action
public execute ( string $controllerAction = null, array $args = [] ) : Response
$controllerAction string Override the controller action to execute as.
$args array List of arguments to pass to the CRUD action (Usually an ID to edit / delete).
Результат Cake\Network\Response

findMethod() публичный Метод

To map multiple findMethods in one go pass an array as first argument and no second argument.
public findMethod ( string | array $action, string | null $method = null ) : void
$action string | array Action or array of actions.
$method string | null Find method name
Результат void

getSubject() публичный Метод

Create a CakeEvent subject with the required properties.
public getSubject ( array $additional = [] ) : Crud\Event\Subject
$additional array Additional properties for the subject.
Результат Crud\Event\Subject

isActionMapped() публичный Метод

Check if a CRUD action has been mapped (whether it will be handled by CRUD component)
public isActionMapped ( string | null $action = null ) : boolean
$action string | null If null, use the current action.
Результат boolean

listener() публичный Метод

Get a single event class.
public listener ( string $name ) : BaseListener
$name string Listener
Результат Crud\Listener\BaseListener

logEvent() публичный Метод

Add a log entry for the event.
public logEvent ( string $eventName, array $data = [] ) : void
$eventName string Event name
$data array Event data
Результат void

mapAction() публичный Метод

Map action to an internal request type.
public mapAction ( string $action, string | array $config = [], boolean $enable = true ) : void
$action string The Controller action to provide an implementation for.
$config string | array Config array or class name like Crud.Index.
$enable boolean Should the mapping be enabled right away?
Результат void

normalizeArray() публичный Метод

Normalize config array
public normalizeArray ( array $array ) : array
$array array List to normalize
Результат array

on() публичный Метод

Attaches an event listener function to the controller for Crud Events.
public on ( string | array $events, callback $callback, array $options = [] ) : void
$events string | array Name of the Crud Event you want to attach to controller.
$callback callback Callable method or closure to be executed on event.
$options array Used to set the `priority` and `passParams` flags to the listener.
Результат void

removeListener() публичный Метод

This will also detach it from the EventManager if it's attached.
public removeListener ( string $name ) : boolean
$name string Name
Результат boolean

startup() публичный Метод

Called after the Controller::beforeFilter() and before the controller action.
public startup ( Cake\Event\Event $event ) : void
$event Cake\Event\Event Event instance
Результат void

table() публичный Метод

Returns controller's table instance.
public table ( ) : Table
Результат Cake\ORM\Table

trigger() публичный Метод

If Event listeners return a CakeResponse object, the this method will throw an exception and fill a 'response' property on it with a reference to the response object.
public trigger ( string $eventName, Crud\Event\Subject $data = null ) : Cake\Event\Event
$eventName string Event name
$data Crud\Event\Subject Event data
Результат Cake\Event\Event

useModel() публичный Метод

Sets the model class to be used during the action execution.
public useModel ( string $modelName ) : void
$modelName string The name of the model to load.
Результат void

view() публичный Метод

To map multiple action views in one go pass an array as first argument and no second argument.
public view ( string | array $action, string | null $view = null ) : void
$action string | array Action or array of actions
$view string | null View name
Результат void

viewVar() публичный Метод

To map multiple action viewVars in one go pass an array as first argument and no second argument.
public viewVar ( string | array $action, string | null $viewVar = null ) : void
$action string | array Action or array of actions.
$viewVar string | null View var name.
Результат void

Описание свойств

$_action защищенное свойство

The current controller action.
protected string $_action
Результат string

$_actionInstances защищенное свойство

List of crud actions.
protected array $_actionInstances
Результат array

$_controller защищенное свойство

Reference to the current controller.
protected Controller,Cake\Controller $_controller
Результат Cake\Controller\Controller

$_defaultConfig защищенное свойство

eventPrefix All emitted events will be prefixed with this property value. actions contains an array of controller methods this component should offer implementation for. Each action maps to a CrudAction class. $controllerAction => $crudActionClass. Example: array('admin_index' => 'Crud.Index') By default no actions are enabled. listeners List of internal-name => ${plugin}.${class} listeners that will be bound automatically in Crud. By default the related model event are bound. Events will always assume to be in the Controller/Event folder. eventLogging boolean to determine whether the class should log triggered events.
protected array $_defaultConfig
Результат array

$_eventLog защищенное свойство

A flat array of the events triggered.
protected array $_eventLog
Результат array

$_eventManager защищенное свойство

Reference to the current event manager.
protected EventManager,Cake\Event $_eventManager
Результат Cake\Event\EventManager

$_listenerInstances защищенное свойство

List of listener objects attached to Crud.
protected array $_listenerInstances
Результат array

$_modelName защищенное свойство

Cached property for Controller::$modelClass. This is the model name of the current model.
protected string $_modelName
Результат string

$_request защищенное свойство

Reference to the current request.
protected Request,Cake\Network $_request
Результат Cake\Network\Request