PHP Класс FOF30\Model\Model

A generic MVC model implementation
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$_ignoreRequest boolean Should we ignore request data when trying to get state data not already set in the Model?
$_savestate boolean Should I save the model's state in the session?
$_state_set boolean Are the state variables already set?
$container FOF30\Container\Container The container attached to the model
$name string The model (base) name
$state string A state object

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

Метод Описание
__call ( string $name, mixed $arguments ) : static Magic caller; allows to use the name of model state keys as methods to set their values.
__construct ( Container $container, array $config = [] ) Public class constructor
__get ( string $name ) : static Magic getter; allows to use the name of model state keys as properties. Also handles magic properties: $this->input mapped to $this->container->input
__set ( string $name, mixed $value ) : static Magic setter; allows to use the name of model state keys as properties
clearState ( ) : static Clears the model state, but doesn't touch the internal lists of records, record tables or record id variables. To clear these values, please use reset().
getClone ( ) Clones the model object and returns the clone
getContainer ( ) : Container Returns a reference to the model's container
getHash ( ) : string Returns a unique hash for each view, used to prefix the state variables to allow us to retrieve them from the state later on.
getIgnoreRequest ( ) : boolean Gets the ignore request flag. When false, getState() will try to populate state variables not already set from same-named state variables in the request.
getName ( ) : string Method to get the model name
getState ( string $key = null, mixed $default = null, string $filter_type = 'raw' ) : mixed Get a filtered state variable
populateSavestate ( ) : static Public setter for the _savestate variable. Set it to true to save the state of the Model in the session.
savestate ( boolean $newState ) : static Sets the model state auto-save status. By default the model is set up to save its state to the session.
setIgnoreRequest ( boolean $ignoreRequest ) Sets the ignore request flag. When false, getState() will try to populate state variables not already set from same-named state variables in the request.
setState ( string $property, mixed $value = null ) : mixed Method to set model state variables
tmpInstance ( ) Returns a temporary instance of the model. Please note that this returns a _clone_ of the model object, not the original object. The new object is set up to not save its stats, ignore the request when getting state variables and comes with an empty state.

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

Метод Описание
populateState ( ) : void Method to auto-populate the model state.
triggerEvent ( string $event, array $arguments = [] ) : void Triggers an object-specific event. The event runs both locally –if a suitable method exists– and through the object's behaviours dispatcher and Joomla! plugin system. Neither handler is expected to return anything (return values are ignored). If you want to mark an error and cancel the event you have to raise an exception.

Приватные методы

Метод Описание
internal_getState ( string $property = null, mixed $default = null ) : object Method to get model state variables

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

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

Magic caller; allows to use the name of model state keys as methods to set their values.
public __call ( string $name, mixed $arguments ) : static
$name string The state variable key
$arguments mixed The state variable contents
Результат static

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

You can use the $config array to pass some configuration values to the object: state stdClass|array. The state variables of the Model. use_populate Boolean. When true the model will set its state from populateState() instead of the request. ignore_request Boolean. When true getState will not automatically load state data from the request.
public __construct ( Container $container, array $config = [] )
$container FOF30\Container\Container The configuration variables to this model
$config array Configuration values for this model

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

Magic getter; allows to use the name of model state keys as properties. Also handles magic properties: $this->input mapped to $this->container->input
public __get ( string $name ) : static
$name string The state variable key
Результат static

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

Magic setter; allows to use the name of model state keys as properties
public __set ( string $name, mixed $value ) : static
$name string The state variable key
$value mixed The state variable value
Результат static

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

Clears the model state, but doesn't touch the internal lists of records, record tables or record id variables. To clear these values, please use reset().
public clearState ( ) : static
Результат static

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

Clones the model object and returns the clone
public getClone ( )

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

Returns a reference to the model's container
public getContainer ( ) : Container
Результат FOF30\Container\Container

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

Returns a unique hash for each view, used to prefix the state variables to allow us to retrieve them from the state later on.
public getHash ( ) : string
Результат string

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

Gets the ignore request flag. When false, getState() will try to populate state variables not already set from same-named state variables in the request.
public getIgnoreRequest ( ) : boolean
Результат boolean

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

The model name. By default parsed using the classname or it can be set by passing a $config['name'] in the class constructor
public getName ( ) : string
Результат string The name of the model

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

Get a filtered state variable
public getState ( string $key = null, mixed $default = null, string $filter_type = 'raw' ) : mixed
$key string The state variable's name
$default mixed The default value to return if it's not already set
$filter_type string The filter type to use
Результат mixed The state variable's contents

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

Public setter for the _savestate variable. Set it to true to save the state of the Model in the session.
public populateSavestate ( ) : static
Результат static

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

This method should only be called once per instantiation and is designed to be called on the first call to the getState() method unless the model configuration flag to ignore the request is set.
protected populateState ( ) : void
Результат void

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

Sets the model state auto-save status. By default the model is set up to save its state to the session.
public savestate ( boolean $newState ) : static
$newState boolean True to save the state, false to not save it.
Результат static

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

Sets the ignore request flag. When false, getState() will try to populate state variables not already set from same-named state variables in the request.
public setIgnoreRequest ( boolean $ignoreRequest )
$ignoreRequest boolean

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

Method to set model state variables
public setState ( string $property, mixed $value = null ) : mixed
$property string The name of the property.
$value mixed The value of the property to set or null.
Результат mixed The previous value of the property or null if not set.

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

Returns a temporary instance of the model. Please note that this returns a _clone_ of the model object, not the original object. The new object is set up to not save its stats, ignore the request when getting state variables and comes with an empty state.
public tmpInstance ( )

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

EXAMPLE Component: com_foobar, Object name: item, Event: onBeforeSomething, Arguments: array(123, 456) The event calls: 1. $this->onBeforeSomething(123, 456) 2. $his->behavioursDispatcher->trigger('onBeforeSomething', array(&$this, 123, 456)) 3. Joomla! plugin event onComFoobarModelItemBeforeSomething($this, 123, 456)
protected triggerEvent ( string $event, array $arguments = [] ) : void
$event string The name of the event, typically named onPredicateVerb e.g. onBeforeKick
$arguments array The arguments to pass to the event handlers
Результат void

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

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

Should we ignore request data when trying to get state data not already set in the Model?
protected bool $_ignoreRequest
Результат boolean

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

Should I save the model's state in the session?
protected bool $_savestate
Результат boolean

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

Are the state variables already set?
protected bool $_state_set
Результат boolean

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

The container attached to the model
protected Container,FOF30\Container $container
Результат FOF30\Container\Container

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

The model (base) name
protected string $name
Результат string

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

A state object
protected string $state
Результат string