PHP 클래스 Craft\NeoService

상속: extends craft\BaseApplicationComponent
파일 보기 프로젝트 열기: benjamminf/craft-neo

공개 프로퍼티들

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