\Field\Model\TableFieldInstancesTable

Represents "field_instances" database table.

This table holds information about all fields attached to tables. It also triggers Field Instances's events:

  • Field.<FieldHandler>.Instance.info: When QuickAppsCMS asks for information about each registered Field
  • Field.<FieldHandler>.Instance.settingsForm: Additional settings for this field. Should define the way the values will be stored in the database.
  • Field.<FieldHandler>.Instance.settingsDefaults: Default values for field settings form's inputs
  • Field.<FieldHandler>.Instance.viewModeForm: Additional formatter options. Show define the way the values will be rendered for a particular view mode.
  • Field.<FieldHandler>.Instance.viewModeDefaults: Default values for view mode settings form's inputs
  • Field.<FieldHandler>.Instance.beforeAttach: Before field is attached to Tables
  • Field.<FieldHandler>.Instance.afterAttach: After field is attached to Tables
  • Field.<FieldHandler>.Instance.beforeDetach: Before field is detached from Tables
  • Field.<FieldHandler>.Instance.afterDetach: After field is detached from Tables

Summary

Methods
Properties
Constants
initialize()
buildRules()
validationDefault()
validationSettings()
validationViewMode()
beforeFind()
beforeSave()
afterSave()
beforeDelete()
afterDelete()
trigger()
eventDispatcher()
triggered()
viewMode()
addViewMode()
viewModes()
onViewMode()
asViewMode()
No public properties found
No constants found
No protected methods found
$_deleted
N/A
No private methods found
No private properties found
N/A

Properties

$_deleted

$_deleted : \Cake\Datasource\EntityInterface|null

Used to deleted associated "belongsTo" EavAttributes.

Type

\Cake\Datasource\EntityInterface|null

Methods

initialize()

initialize(array $config) : void

Initialize a table instance. Called after the constructor.

Parameters

array $config

Configuration options passed to the constructor

buildRules()

buildRules(\Cake\ORM\RulesChecker $rules) : \Cake\ORM\RulesChecker

Application rules.

Parameters

\Cake\ORM\RulesChecker $rules

The rule checker

Returns

\Cake\ORM\RulesChecker

validationDefault()

validationDefault(\Cake\Validation\Validator $validator) : \Cake\Validation\Validator

Default validation rules set.

Parameters

\Cake\Validation\Validator $validator

The validator object

Returns

\Cake\Validation\Validator

validationSettings()

validationSettings(\Cake\Validation\Validator $validator) : \Cake\Validation\Validator

Instance's settings validator.

Parameters

\Cake\Validation\Validator $validator

The validator object

Returns

\Cake\Validation\Validator

validationViewMode()

validationViewMode(\Cake\Validation\Validator $validator) : \Cake\Validation\Validator

Instance's view mode validator.

This rules are apply to a single view mode.

Parameters

\Cake\Validation\Validator $validator

The validator object

Returns

\Cake\Validation\Validator

beforeFind()

beforeFind(\Cake\Event\Event $event, \Cake\ORM\Query $query, \ArrayObject $options, boolean $primary) : void

Here we set default values for each view mode if they were not defined before.

Parameters

\Cake\Event\Event $event

The event that was triggered

\Cake\ORM\Query $query

The query object

\ArrayObject $options

Additional options given as an array

boolean $primary

Whether this find is a primary query or not

beforeSave()

beforeSave(\Cake\Event\Event $event, \Field\Model\Entity\FieldInstance $instance, \ArrayObject $options) : boolean

Triggers the "Field.<FieldHandler>.Instance.beforeAttach" event.

Parameters

\Cake\Event\Event $event

The event that was triggered

\Field\Model\Entity\FieldInstance $instance

The Field Instance that is going to be saved

\ArrayObject $options

The options passed to the save method

Returns

boolean —

False if save operation should not continue, true otherwise

afterSave()

afterSave(\Cake\Event\Event $event, \Field\Model\Entity\FieldInstance $instance, \ArrayObject $options) : void

Triggers the "Field.<FieldHandler>.Instance.afterAttach" event.

Parameters

\Cake\Event\Event $event

The event that was triggered

\Field\Model\Entity\FieldInstance $instance

The Field Instance that was saved

\ArrayObject $options

the options passed to the save method

beforeDelete()

beforeDelete(\Cake\Event\Event $event, \Field\Model\Entity\FieldInstance $instance, \ArrayObject $options) : boolean

Triggers the "Field.<FieldHandler>.Instance.beforeDetach" event.

Parameters

\Cake\Event\Event $event

The event that was triggered

\Field\Model\Entity\FieldInstance $instance

The Field Instance that is going to be deleted

\ArrayObject $options

the options passed to the delete method

Returns

boolean —

False if delete operation should not continue, true otherwise

afterDelete()

afterDelete(\Cake\Event\Event $event, \Field\Model\Entity\FieldInstance $instance, \ArrayObject $options) : void

Triggers the "Field.<FieldHandler>.Instance.afterDetach" event.

it also deletes all associated records in the field_values table.

Parameters

\Cake\Event\Event $event

The event that was triggered

\Field\Model\Entity\FieldInstance $instance

The Field Instance that was deleted

\ArrayObject $options

the options passed to the delete method

trigger()

trigger(array|string $eventName) : \Cake\Event\Event

Triggers the given event name. This method provides a shortcut for:

$this->trigger('EventName', $arg1, $arg2, ..., $argn);

You can provide a subject to use by passing an array as first arguments where the first element is the event name and the second one is the subject, if no subject is given $this will be used by default:

$this->trigger(['GetTime', new MySubject()], $arg_0, $arg_1, ..., $arg_n);

You can also indicate an EventDispatcher instance to use by prefixing the event name with <InstanceName>::, for instance:

$this->trigger('Blog::EventName', $arg1, $arg2, ..., $argn);

This will use the EventDispacher instance named Blog and will trigger the event EventName within that instance.

Parameters

array|string $eventName

The event name to trigger

Returns

\Cake\Event\Event —

The event object that was fired

eventDispatcher()

eventDispatcher(string $name) : \QuickApps\Event\EventDispatcher

Gets an instance of the given Event Dispatcher name.

Usage:

$this->eventDispatcher('myDispatcher')
    ->trigger('MyEventName', $argument)
    ->result;

Parameters

string $name

Name of the dispatcher to get, defaults to 'default'

Returns

\QuickApps\Event\EventDispatcher

triggered()

triggered(string|null $eventName) : integer|array

Retrieves the number of times an event was triggered, or the complete list of events that were triggered.

Parameters

string|null $eventName

The name of the event, if null returns the entire list of event that were fired

Returns

integer|array

viewMode()

viewMode(string|null $slug) : void

Sets a view mode or get current view mode.

Parameters

string|null $slug

Slug name of the view mode

addViewMode()

addViewMode(string|array $slug, string|null $name, string|null $description) : void

Registers a new view mode. Or overwrite if already exists.

Parameters

string|array $slug

Slug name of your view mode. e.g.: my-view mode. Or an array of view modes to register indexed by slug name

string|null $name

Human readable name. e.g.: My View Mode

string|null $description

A brief description about for what is this view mode

viewModes()

viewModes(boolean|string $viewMode) : array

Gets the full list of all registered view modes, or for a single view mode if $viewMode is set to a string value.

Parameters

boolean|string $viewMode

Set to true to get full list. Or false (by default) to get only the slug of all registered view modes. Or set to a string value to get information for that view mode only.

Returns

array

onViewMode()

onViewMode(string|array $viewMode, callable $method) : mixed

Runs the given callable when the in-use view mode matches.

You can provide multiple view modes, in that case callable method will be executed if current view mode matches any in the given array.

Usage

// run this only on `teaser` view mode
echo $this->onViewMode('teaser', function () use ($someVar) {
    return $this->element('teaser_element', compact('someVar'));
});

// run this on "teaser" view mode, or "search-result" view mode
echo $this->onViewMode(['teaser', 'search-result'], function () use ($someVar) {
    return $this->element('teaser_or_search_result', compact('someVar'));
});

Parameters

string|array $viewMode

View Mode slug, or an array of slugs

callable $method

A callable function to run, it receives $this as only argument

Returns

mixed —

Callable return

asViewMode()

asViewMode(string|array $viewMode, callable $method) : mixed

Runs the given callable as it were under the given view mode.

Usage

$this->viewMode('full');
echo 'before: ' . $this->viewMode();

echo $this->asViewMode('teaser', function () {
     echo 'callable: ' . $this->viewMode();
});

echo 'after: ' . $this->viewMode();

// output:
// before: full
// callable: teaser
// after: full

Parameters

string|array $viewMode

View Mode slug, or an array of slugs

callable $method

A callable function to run, it receives $this as only argument

Returns

mixed —

Callable return