PHP Класс Craft\NeoService

Наследование: extends craft\BaseApplicationComponent
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
$currentSavingBlockType Neo_BlockTypeModel | null

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

Метод Описание
deleteBlockById ( array\int $blockIds ) : boolean Deletes a block (or series of blocks) by it's ID from the database.
deleteBlockType ( Neo_BlockTypeModel $blockType ) : boolean Deletes a block type from the database.
deleteField ( craft\FieldModel $neoField ) Deletes a Neo field from the database.
deleteGroupsByFieldId ( $fieldId ) : boolean Deletes all groups associated with a field from the database.
deleteStructure ( NeoFieldType $fieldType ) : boolean Deletes the structure for a field from the database.
getBlockById ( integer $blockId, integer | null $localeId = null ) : Neo_BlockModel Returns a block given it's ID.
getBlockTypeById ( $blockTypeId ) : Neo_BlockTypeModel Finds a block type by it's ID.
getBlockTypesByFieldId ( $fieldId, string | null $indexBy = null ) : array Returns a list of block types associated with a field.
getBlocks ( integer $fieldId, integer $ownerId, string | null $locale = null ) : array
getCriteria ( mixed | null $attributes = null ) : Neo_CriteriaModel Creates a Neo-specific element criteria model.
getGroupsByFieldId ( $fieldId, string | null $indexBy = null ) : array Returns a list of groups associated with a field.
getStructure ( NeoFieldType $fieldType ) : craft\StructureModel | boolean Returns the structure for a field.
isPreviewMode ( ) : boolean Checks the current route/environment to see if database calls for Neo blocks should be avoided.
renderBlockTabs ( Neo_BlockTypeModel $blockType, Neo_BlockModel $block = null, string $namespace = '', boolean | false $static = false, $locale = null ) : array Builds the HTML for an individual block type.
requirePlugin ( $plugin ) Forces a plugin to exist by throwing an error if it doesn't.
saveBlock ( Neo_BlockModel $block, boolean | true $validate = true ) : boolean Saves a block to the database.
saveBlockCollapse ( Neo_BlockModel $block ) : boolean Saves a block's expansion state to the database.
saveBlockType ( Neo_BlockTypeModel $blockType, boolean | true $validate = true ) : boolean Saves a block type to the database.
saveFieldValue ( NeoFieldType $fieldType ) Saves a Neo field's value to the database.
saveGroup ( Neo_GroupModel $group ) : boolean Saves a group to the database.
saveSettings ( Neo_SettingsModel $settings, boolean | true $validate = true ) : boolean Saves a field's settings to the database.
saveStructure ( craft\StructureModel $structure, NeoFieldType $fieldType ) : boolean Saves the structure for a field to the database.
validateBlock ( Neo_BlockModel $block ) : boolean Runs validation on a block, and saves any errors to the block.
validateBlockType ( Neo_BlockTypeModel $blockType, boolean | true $validateUniques = true ) : boolean Runs validation on a block type, and saves any errors to the block type.
validateFieldSettings ( Neo_SettingsModel $settings ) : boolean Validates a field's settings, loading the settings and block type models with any error messages.

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

Метод Описание
beginTransaction ( ) : CDbTransaction | null Returns a new database transaction if one hasn't already been created.
commitTransaction ( CDbTransaction $transaction ) Commits a database transaction if transaction is not null.
rollbackTransaction ( CDbTransaction $transaction ) Rolls back a database transaction if transaction is not null.

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

Метод Описание
_applyFieldTranslationSetting ( $owner, $field, $blocks ) Applies a field's translation setting to any existing values of the field.
_createBlockTypeQuery ( ) : mixed Creates a base database query for all block types.
_createGroupQuery ( ) : mixed Creates a base database query for all groups.
_getBlockRecord ( Neo_BlockModel $block ) : Neo_BlockRecord Finds and returns the block record from a block model.
_getBlockTypeRecord ( Neo_BlockTypeModel $blockType ) : Neo_BlockTypeRecord Finds and returns the block type record from a block type model.
_getFieldLocale ( NeoFieldType $fieldType ) : string | null Returns the locale for a given field if it's set to be translatable, otherwise returns null.
_indexBy ( $list, $property ) : array Changes how an array is indexed based on it's containing objects properties.

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

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

Returns a new database transaction if one hasn't already been created.
protected beginTransaction ( ) : CDbTransaction | null
Результат CDbTransaction | null

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

Commits a database transaction if transaction is not null.
protected commitTransaction ( CDbTransaction $transaction )
$transaction CDbTransaction

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

Deletes a block (or series of blocks) by it's ID from the database.
public deleteBlockById ( array\int $blockIds ) : boolean
$blockIds array\int
Результат boolean

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

Deletes a block type from the database.
public deleteBlockType ( Neo_BlockTypeModel $blockType ) : boolean
$blockType Neo_BlockTypeModel
Результат boolean

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

Deletes a Neo field from the database.
public deleteField ( craft\FieldModel $neoField )
$neoField craft\FieldModel

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

Deletes all groups associated with a field from the database.
public deleteGroupsByFieldId ( $fieldId ) : boolean
$fieldId
Результат boolean

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

Deletes the structure for a field from the database.
public deleteStructure ( NeoFieldType $fieldType ) : boolean
$fieldType NeoFieldType
Результат boolean

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

Returns a block given it's ID.
public getBlockById ( integer $blockId, integer | null $localeId = null ) : Neo_BlockModel
$blockId integer
$localeId integer | null
Результат Neo_BlockModel

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

Finds a block type by it's ID.
public getBlockTypeById ( $blockTypeId ) : Neo_BlockTypeModel
$blockTypeId
Результат Neo_BlockTypeModel

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

Returns a list of block types associated with a field.
public getBlockTypesByFieldId ( $fieldId, string | null $indexBy = null ) : array
$fieldId
$indexBy string | null
Результат array

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

public getBlocks ( integer $fieldId, integer $ownerId, string | null $locale = null ) : array
$fieldId integer
$ownerId integer
$locale string | null
Результат array

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

Creates a Neo-specific element criteria model.
public getCriteria ( mixed | null $attributes = null ) : Neo_CriteriaModel
$attributes mixed | null
Результат Neo_CriteriaModel

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

Returns a list of groups associated with a field.
public getGroupsByFieldId ( $fieldId, string | null $indexBy = null ) : array
$fieldId
$indexBy string | null
Результат array

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

Returns the structure for a field.
public getStructure ( NeoFieldType $fieldType ) : craft\StructureModel | boolean
$fieldType NeoFieldType
Результат craft\StructureModel | boolean

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

This is so that live preview and entry drafts can use their data instead.
public isPreviewMode ( ) : boolean
Результат boolean

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

If you don't pass in a block along with the type, then it'll render a base template to build real blocks from. If you do pass in a block, then it's current field values will be rendered as well.
public renderBlockTabs ( Neo_BlockTypeModel $blockType, Neo_BlockModel $block = null, string $namespace = '', boolean | false $static = false, $locale = null ) : array
$blockType Neo_BlockTypeModel
$block Neo_BlockModel
$namespace string
$static boolean | false
$locale
Результат array

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

Used when supporting other plugins, such as Relabel and Reasons.
public requirePlugin ( $plugin )
$plugin

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

Rolls back a database transaction if transaction is not null.
protected rollbackTransaction ( CDbTransaction $transaction )
$transaction CDbTransaction

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

Saves a block to the database.
public saveBlock ( Neo_BlockModel $block, boolean | true $validate = true ) : boolean
$block Neo_BlockModel
$validate boolean | true
Результат boolean

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

It bypasses the elements system and performs a direct database query. This is so it doesn't cause caches to be regenerated. It's also more performant, which comes in handy when this is called in AJAX requests.
public saveBlockCollapse ( Neo_BlockModel $block ) : boolean
$block Neo_BlockModel
Результат boolean

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

Saves a block type to the database.
public saveBlockType ( Neo_BlockTypeModel $blockType, boolean | true $validate = true ) : boolean
$blockType Neo_BlockTypeModel
$validate boolean | true
Результат boolean

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

Saves a Neo field's value to the database.
public saveFieldValue ( NeoFieldType $fieldType )
$fieldType NeoFieldType

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

Saves a group to the database.
public saveGroup ( Neo_GroupModel $group ) : boolean
$group Neo_GroupModel
Результат boolean

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

Saves a field's settings to the database.
public saveSettings ( Neo_SettingsModel $settings, boolean | true $validate = true ) : boolean
$settings Neo_SettingsModel
$validate boolean | true
Результат boolean

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

Saves the structure for a field to the database.
public saveStructure ( craft\StructureModel $structure, NeoFieldType $fieldType ) : boolean
$structure craft\StructureModel
$fieldType NeoFieldType
Результат boolean

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

Runs validation on a block, and saves any errors to the block.
public validateBlock ( Neo_BlockModel $block ) : boolean
$block Neo_BlockModel
Результат boolean

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

Runs validation on a block type, and saves any errors to the block type.
public validateBlockType ( Neo_BlockTypeModel $blockType, boolean | true $validateUniques = true ) : boolean
$blockType Neo_BlockTypeModel
$validateUniques boolean | true
Результат boolean

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

Validates a field's settings, loading the settings and block type models with any error messages.
public validateFieldSettings ( Neo_SettingsModel $settings ) : boolean
$settings Neo_SettingsModel
Результат boolean

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

$currentSavingBlockType публичное свойство

public Neo_BlockTypeModel,craft|null $currentSavingBlockType
Результат Neo_BlockTypeModel | null