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
파일 보기 프로젝트 열기: friendsofcake/crud 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_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