Data writer for permission groups.
Data writers focus on writing a unit of data to the database, including verifying all data to the application rules (including those set by the owner) and doing denormalized updates as necessary.
The writer may also interact with the cache, if required.
| package | XenForo_Permissions |
|---|
__construct(\constant $errorHandler, array $inject)
| inherited_from | \XenForo_DataWriter::__construct() |
|---|
\constantError handler. See {@link ERROR_EXCEPTION} and related.
arraynullDependency injector. Array keys available: db, cache.
bulkSet(array $fields, array $options)
| inherited_from | \XenForo_DataWriter::bulkSet() |
|---|
arrayKey-value pairs of fields and values.
arrayOptions to pass into {@link set()}. See {@link $_setOptions}.
create(string $class, \constant $errorHandler, array $inject) : \XenForo_DataWriter
The class must exist or be autoloadable or an exception will be thrown.
| inherited_from | \XenForo_DataWriter::create() |
|---|
stringClass to load
\constantError handler. See {@link ERROR_EXCEPTION} and related.
arraynullDependencies to inject. See {@link __construct()}.
delete() : boolean
| inherited_from | \XenForo_DataWriter::delete() |
|---|
booleanTrue on successerror(string | \XenForo_Phrase $error, string | false $errorKey, boolean $specificError)
Depending on the type of error handler chosen, this may throw an exception.
| inherited_from | \XenForo_DataWriter::error() |
|---|
stringfalseUnique key for the error. Used to prevent multiple errors from the same field being displayed.
booleanIf true and error key specified, overwrites an existing error with this name
get(string $field, string $tableName) : mixed
| inherited_from | \XenForo_DataWriter::get() |
|---|
stringField name
stringTable name, if empty loops through tables until first match
mixedReturns null if the specified field could not be found.getError(string $errorKey) : string
| inherited_from | \XenForo_DataWriter::getError() |
|---|
string
stringgetErrors() : array
getExisting(string $field, string $tableName) : mixed
Returns null if not set.
| inherited_from | \XenForo_DataWriter::getExisting() |
|---|
stringField name
stringTable name, if empty loops through tables until first match
mixedgetExtraData(string $name) : mixed
| inherited_from | \XenForo_DataWriter::getExtraData() |
|---|
string
mixedgetFieldNames($tableName)
| inherited_from | \XenForo_DataWriter::getFieldNames() |
|---|
getMergedData(string $tableName) : array
This will generally reflect what is in the database.
If no table is specified, all data will be flattened into one array. New data takes priority over existing data, and earlier tables in the list take priority over later tables.
| inherited_from | \XenForo_DataWriter::getMergedData() |
|---|
string
arraygetMergedExistingData(string $tableName) : array
| inherited_from | \XenForo_DataWriter::getMergedExistingData() |
|---|
string
arraygetMergedNewData(string $tableName)
| inherited_from | \XenForo_DataWriter::getMergedNewData() |
|---|
string
getModelFromCache(string $class) : \XenForo_Model
If it does not exist, it will be instantiated.
| inherited_from | \XenForo_DataWriter::getModelFromCache() |
|---|
stringName of the class to load
getNew(string $field, string $tableName) : mixed
Returns null if not set.
| inherited_from | \XenForo_DataWriter::getNew() |
|---|
stringField name
stringTable name, if empty loops through tables until first match
mixedgetNewData() : array
| inherited_from | \XenForo_DataWriter::getNewData() |
|---|
arraygetOption(string $name) : mixed
The meaning of this option is completely domain specific. If an unknown option specified, an exception will be triggered.
| inherited_from | \XenForo_DataWriter::getOption() |
|---|
stringName of the option to get
mixedValue of the optiongetTablesDataFromArray(array $dataArray) : array
In order for this to work, the following must be true: 1) The input array must provide all data that this datawriter requires 2) There can be no overlapping field names in the tables that define this data, unless those fields all store the same value 3) IMPORTANT: If the input array does not include all the required data fields, it is your responsibility to provide it after this function returns.
| inherited_from | \XenForo_DataWriter::getTablesDataFromArray() |
|---|
arrayComplete data record
arraygetUpdateCondition(string $tableName) : string
If there is no existing data, this always returns an empty string, otherwise it proxies to _getUpdateCondition(), which is an abstract function.
| inherited_from | \XenForo_DataWriter::getUpdateCondition() |
|---|
stringName of the table to fetch the condition for
stringhasChanges() : boolean
| inherited_from | \XenForo_DataWriter::hasChanges() |
|---|
booleanhasErrors() : boolean
| inherited_from | \XenForo_DataWriter::hasErrors() |
|---|
booleanisChanged(string $field, string $tableName) : boolean
| inherited_from | \XenForo_DataWriter::isChanged() |
|---|
stringField name
stringTable name, if empty loops through tables until first match
booleanisExtraDataSet(string $name) : boolean
| inherited_from | \XenForo_DataWriter::isExtraDataSet() |
|---|
string
booleanisInsert() : boolean
| inherited_from | \XenForo_DataWriter::isInsert() |
|---|
booleanisUpdate() : boolean
| inherited_from | \XenForo_DataWriter::isUpdate() |
|---|
booleanmergeErrors(array $errors)
| inherited_from | \XenForo_DataWriter::mergeErrors() |
|---|
array
preDelete()
Any verification or complex defaults may be set by this.
It is generally not advisable to override this function. If you just want to add pre-delete behaviors, override _preDelete().
| inherited_from | \XenForo_DataWriter::preDelete() |
|---|
preSave()
Any verification or complex defaults may be set by this.
It is generally not advisable to override this function. If you just want to add pre-save behaviors, override _preSave().
| inherited_from | \XenForo_DataWriter::preSave() |
|---|
save() : boolean
This either updates an existing record or inserts a new one, depending whether setExistingData was called.
After a successful insert with an auto_increment field, the value will be stored into the new data array with a field marked as autoIncrement. Use get() to get access to it.
| inherited_from | \XenForo_DataWriter::save() |
|---|
booleanTrue on successset(string $field, string $value, string $tableName, array $options) : boolean
This value will be updated when save is called.
| inherited_from | \XenForo_DataWriter::set() |
|---|
stringName of field to update
stringValue to update with
stringTable name, if empty then all tables with that column
arrayOptions. See {@link $_setOptions).
booleansetDefaultSetOptions(array $setOptions)
See $_setOptions for the available options.
| inherited_from | \XenForo_DataWriter::setDefaultSetOptions() |
|---|
array
setErrorHandler(integer $errorHandler)
| inherited_from | \XenForo_DataWriter::setErrorHandler() |
|---|
integer
setExistingData(mixed $data, boolean $trustInputAsPrimary) : boolean
This causes the system to do an update instead of an insert. This function triggers an error if no data can be fetched from the provided data.
| inherited_from | \XenForo_DataWriter::setExistingData() |
|---|
mixedData that can uniquely ID this item
booleanIf true, trust the passed data to be based on data in DB; if false, the data is used as is (if it's an array)
booleansetExtraData(string $name, mixed $value)
The DW should be able to function without this data.
| inherited_from | \XenForo_DataWriter::setExtraData() |
|---|
stringName of the data
mixedValue of the data
setImportMode(\boolean$mode $mode)
When enabled, preSave, postSave, and verification functions are disabled.
| inherited_from | \XenForo_DataWriter::setImportMode() |
|---|
\boolean$mode
setOption(string $name, mixed $value)
The meaning of this option is completely domain specific. If an unknown option specified, an exception will be triggered.
| inherited_from | \XenForo_DataWriter::setOption() |
|---|
stringName of the option to set
mixedValue of the option
updateVersionId(string $versionIdField, string $versionStringField, string $addOnIdField) : integer
Th add-on ID is determined from a previously set value, so it should not be updated after this is called.
| inherited_from | \XenForo_DataWriter::updateVersionId() |
|---|
stringName of the field the version ID will be written to
stringName of the field where the version string will be written to
stringName of the field the add-on ID is kept in
integerVersion ID to use_applyFieldValueLimits(string $fieldType, mixed $value, array $extraLimits) : boolean | string
Returns true if the field meets the constraints. The passed in value will be modified by reference.
| inherited_from | \XenForo_DataWriter::_applyFieldValueLimits() |
|---|
stringType of the field. See the TYPE_* constants.
mixedValue for the field.
arrayExtra constraints
booleanstringEither TRUE or an error message_beginDbTransaction()
| inherited_from | \XenForo_DataWriter::_beginDbTransaction() |
|---|
_castValueToType(string $fieldType, mixed $value, string $fieldName, array $fieldData) : mixed
| inherited_from | \XenForo_DataWriter::_castValueToType() |
|---|
stringType to cast to
mixedValue to cast
stringName of the field being cast
arrayArray of all field data information, for extra options
mixed_checkRequiredFieldsForUpdate()
| inherited_from | \XenForo_DataWriter::_checkRequiredFieldsForUpdate() |
|---|
_commitDbTransaction()
| inherited_from | \XenForo_DataWriter::_commitDbTransaction() |
|---|
_delete()
Actually does the delete.
| inherited_from | \XenForo_DataWriter::_delete() |
|---|
_deleteMasterPhrase(string $title)
| inherited_from | \XenForo_DataWriter::_deleteMasterPhrase() |
|---|
string
_getAutoIncrementField(string $tableName) : string | false
This field is simply the first field tagged with the autoIncrement flag.
| inherited_from | \XenForo_DataWriter::_getAutoIncrementField() |
|---|
stringName of the table to obtain the field for
stringfalseName of the field if found or false_getCache() : \Zend_Cache_Core | \Zend_Cache_Frontend | false
| inherited_from | \XenForo_DataWriter::_getCache() |
|---|
\Zend_Cache_Core\Zend_Cache_Frontendfalse
_getDefaultOptions() : array
This is automatically called in the constructor. If you wish to set options in your data writer, override this function. As this is handled at run time rather than compile time, you may use dynamic behaviors to set the option defaults.
array_getExistingData(mixed $data) : array | false
See parent for explanation.
mixed
arrayfalse
_getExistingPrimaryKey(mixed $data, string $primaryKeyField, string $tableName) : string | false
| inherited_from | \XenForo_DataWriter::_getExistingPrimaryKey() |
|---|
mixedArray of data containing the primary field or a scalar ID
stringPrimary key field, if data is an array
stringTable name, if empty the first table defined in fields is used
stringfalse
_getFields() : array
See parent for explanation.
array_getPrimaryTable() : string | false
| inherited_from | \XenForo_DataWriter::_getPrimaryTable() |
|---|
stringfalseName of the table or false_getSpecificRequiredFieldErrorText(string $tableName, string $field) : false | string | \XenForo_Phrase
Concrete DWs may override this to get nicer error messages for specific fields.
| inherited_from | \XenForo_DataWriter::_getSpecificRequiredFieldErrorText() |
|---|
string
string
_getTableList(string $tableName) : array
| inherited_from | \XenForo_DataWriter::_getTableList() |
|---|
stringOptional table to limit results to.
array_getTitlePhraseName(string $permissionGroupId) : string
string
string_getUpdateCondition(string $tableName) : string
_haveErrorsPreventSave() : boolean
If the silent error handler is used, errors simply trigger a return of true (yes, we have errors); otherwise, errors trigger an exception. Generally, if errors are to be handled, save shouldn't be called.
| inherited_from | \XenForo_DataWriter::_haveErrorsPreventSave() |
|---|
booleanTrue if there are errors_insert()
| inherited_from | \XenForo_DataWriter::_insert() |
|---|
_insertOrUpdateMasterPhrase(string $title, string $text, string $addOnId, array $extra)
Errors will be silently ignored.
| inherited_from | \XenForo_DataWriter::_insertOrUpdateMasterPhrase() |
|---|
string
string
string
array
_isFieldValueValid(string $fieldName, array $fieldData, mixed $value, array $options) : boolean
The value may be modified based on type, contraints, or other verification methods.
| inherited_from | \XenForo_DataWriter::_isFieldValueValid() |
|---|
stringName of the field.
arrayData about the field (includes type, contraints, callback, etc)
mixedValue for the field
arrayOptions. Uses {@link $_setOptions}.
boolean_performLanguageRebuild()
| inherited_from | \XenForo_DataWriter::_performLanguageRebuild() |
|---|
_postDelete()
_postSave()
This is not called in import mode.
_postSaveAfterTransaction()
This is not called in import mode.
| inherited_from | \XenForo_DataWriter::_postSaveAfterTransaction() |
|---|
_preDelete()
| inherited_from | \XenForo_DataWriter::_preDelete() |
|---|
_preSave()
This is not callbed in import mode.
_preSaveDefaults()
This is still called in import mode.
| inherited_from | \XenForo_DataWriter::_preSaveDefaults() |
|---|
_renameMasterPhrase(string $oldName, string $newName)
If you get a conflict, it will be silently ignored.
| inherited_from | \XenForo_DataWriter::_renameMasterPhrase() |
|---|
string
string
_renameTitlePhrase()
_resolveDefaultsAndRequiredFieldsForInsert(boolean $checkRequired)
If a required field is not set properly, an error is thrown.
| inherited_from | \XenForo_DataWriter::_resolveDefaultsAndRequiredFieldsForInsert() |
|---|
booleanIf true, checks required fields
_rollbackDbTransaction()
| inherited_from | \XenForo_DataWriter::_rollbackDbTransaction() |
|---|
_runVerificationCallback(callback $callback, mixed $value, array $fieldData, $fieldName) : boolean
This callback may modify the value if it chooses to. Callback receives 2 params: the value and this object. The callback must return true if the value was valid.
Returns true if the verification was successful.
| inherited_from | \XenForo_DataWriter::_runVerificationCallback() |
|---|
callbackCallback to run. Use an array with a string '$this' to callback to this object.
mixedValue to verify
arrayInformation about the field, including all constraints to be applied
boolean_save()
Deals with both updates and inserts.
| inherited_from | \XenForo_DataWriter::_save() |
|---|
_setAutoIncrementValue(integer $insertId, string $tableName, bool $updateAll) : boolean
If the ID passed in is 0, nothing will be updated.
| inherited_from | \XenForo_DataWriter::_setAutoIncrementValue() |
|---|
integerAuto-increment value from 0.
stringName of the table set the auto increment field in
boolUpdate all tables with cross referenced auto increment fields
booleanTrue on update_setInternal(string $table, string $field, mixed $newValue, boolean $forceSet)
Use only when you're sure validation, etc isn't needed. The field will only be set if the value has changed.
| inherited_from | \XenForo_DataWriter::_setInternal() |
|---|
stringTable the field belongs to
stringName of the field
mixedValue for the field
booleanIf true, the set always goes through
_setPostSave(string $field, string $newValue, string $tableName, array $options) : boolean
| inherited_from | \XenForo_DataWriter::_setPostSave() |
|---|
stringName of field to update
stringValue to update with
stringTable name, if empty then all tables with that column
arrayOptions. See {@link $_setOptions).
boolean_triggerInvalidExistingDataError()
This can (and generally should) be extended by concrete DWs to give an error that is more specific to their content type.
| inherited_from | \XenForo_DataWriter::_triggerInvalidExistingDataError() |
|---|
_triggerRequiredFieldError(string $tableName, string $field)
| inherited_from | \XenForo_DataWriter::_triggerRequiredFieldError() |
|---|
string
string
_update()
| inherited_from | \XenForo_DataWriter::_update() |
|---|
_updateTitlePhrase()
_verifyPermissionGroupId(string $groupId) : boolean
string
boolean$_cache : \Zend_Cache_Core | \Zend_Cache_Frontend
| inherited_from | \XenForo_DataWriter::$$_cache |
|---|
$_db : \Zend_Db_Adapter_Abstract
| inherited_from | \XenForo_DataWriter::$$_db |
|---|
$_errorHandler : integer
See ERROR_EXCEPTION and related.
| inherited_from | \XenForo_DataWriter::$$_errorHandler |
|---|
$_errors : array
This is always populated when an error occurs, though an exception may be thrown as well.
| inherited_from | \XenForo_DataWriter::$$_errors |
|---|
$_existingData : array
This is only populated when updating a record.
| inherited_from | \XenForo_DataWriter::$$_existingData |
|---|
$_existingDataErrorPhrase : string
$_extraData : array
The DW should usually function without any data in this array. Any data that DW supports should be documented in this array, preferably by the use of constants.
Required data (for example, a related phrase) can be included here if necessary.
| inherited_from | \XenForo_DataWriter::$$_extraData |
|---|
$_fields : array
See _getFields() for more info.
| inherited_from | \XenForo_DataWriter::$$_fields |
|---|
$_importMode : boolean
To be used when using the DW for importing data in bulk. Note that you are responsible for manually replicating the post save effects.
| inherited_from | \XenForo_DataWriter::$$_importMode |
|---|
$_modelCache : array
This is now a static cache to allow data to be reused between data writers, as they are often used in bulk.
| inherited_from | \XenForo_DataWriter::$$_modelCache |
|---|
$_newData : array
| inherited_from | \XenForo_DataWriter::$$_newData |
|---|
$_preDeleteCalled : boolean
It can only be called once.
| inherited_from | \XenForo_DataWriter::$$_preDeleteCalled |
|---|
$_preSaveCalled : boolean
It can only be called once.
| inherited_from | \XenForo_DataWriter::$$_preSaveCalled |
|---|
$_setOptions : array
Available options are: (default value is listed in parentheses) * ignoreInvalidFields (false) - when true, an invalid field is simply ignored; otherwise an error is triggered * replaceInvalidWithDefault (false) - when true, invalid values are replaced with the default value (if there is one) * runVerificationCallback (true) - when true, verification callbacks are run when setting * setAfterPreSave (false) - when true, you may set data after preSave is called. This has very specific uses.
| inherited_from | \XenForo_DataWriter::$$_setOptions |
|---|
$_triggerLanguageRebuild : boolean
| inherited_from | \XenForo_DataWriter::$$_triggerLanguageRebuild |
|---|
DATA_TITLE : string
This value is required on inserts.
ERROR_ARRAY : integer
Use this to push errors onto an array. If you try to save while there are errors, an exception will be thrown.
| inherited_from | \XenForo_DataWriter::ERROR_ARRAY |
|---|
ERROR_EXCEPTION : integer
Use this to trigger an exception when an error occurs.
| inherited_from | \XenForo_DataWriter::ERROR_EXCEPTION |
|---|
ERROR_SILENT : integer
Use this to push errors onto an array. If you try to save while there are errors, the save will silently fail. Use this in places where you aren't interested in handling errors.
| inherited_from | \XenForo_DataWriter::ERROR_SILENT |
|---|
OPTION_REBUILD_CACHE : string
Defaults to true.
TYPE_BINARY : string
Use this for binary or ASCII-only fields. Limits will refer to bytes.
| inherited_from | \XenForo_DataWriter::TYPE_BINARY |
|---|
TYPE_BOOLEAN : string
Use this for 0/1 boolean integer fields.
| inherited_from | \XenForo_DataWriter::TYPE_BOOLEAN |
|---|
TYPE_FLOAT : string
Use this for float fields. Limits can be applied on the range of valid values.
| inherited_from | \XenForo_DataWriter::TYPE_FLOAT |
|---|
TYPE_INT : string
Use this for integer fields. Limits can be applied on the range of valid values.
| inherited_from | \XenForo_DataWriter::TYPE_INT |
|---|
TYPE_JSON : string
| inherited_from | \XenForo_DataWriter::TYPE_JSON |
|---|
TYPE_SERIALIZED : string
Ensures that if the data is not a string, it is serialized to ne.
| inherited_from | \XenForo_DataWriter::TYPE_SERIALIZED |
|---|
TYPE_STRING : string
Use this for string fields. String fields are assumed to be UTF-8 and limits will refer to characters.
| inherited_from | \XenForo_DataWriter::TYPE_STRING |
|---|
TYPE_UINT : string
Use this for unsigned integer fields. Negative values will always fail to be valid. Limits can be applied on the range of valid values.
| inherited_from | \XenForo_DataWriter::TYPE_UINT |
|---|
TYPE_UINT_FORCED : string
Use this for unsigned integer fields. This differs from TYPE_UINT in that negative values will be silently cast to 0. Limits can be applied on the range of valid values.
| inherited_from | \XenForo_DataWriter::TYPE_UINT_FORCED |
|---|
TYPE_UNKNOWN : string
Use this for fields that have a type that cannot be known statically. Use this sparingly, as you must write code to ensure that the value is a scalar before it is inserted into the DB. The behavior if you don't do this is not defined!
| inherited_from | \XenForo_DataWriter::TYPE_UNKNOWN |
|---|