Constants

FIELD_USE_LIKE

FIELD_USE_LIKE = 'use_like' : string

フィールド名

FIELD_USE_UNLIKE

FIELD_USE_UNLIKE = 'use_unlike' : string

フィールド名

FIELD_USE_COMMENT

FIELD_USE_COMMENT = 'use_comment' : string

フィールド名

FIELD_USE_WORKFLOW

FIELD_USE_WORKFLOW = 'use_workflow' : string

フィールド名

FIELD_USE_COMMENT_APPROVAL

FIELD_USE_COMMENT_APPROVAL = 'use_comment_approval' : string

フィールド名

TYPE_BOOLEAN

TYPE_BOOLEAN = 'boolean' : string

フィールド名の種類

TYPE_NUMERIC

TYPE_NUMERIC = 'numeric' : string

フィールド名の種類

Properties

$__fields

$__fields : array

余計なfieldを取得しないために取得するカラム名を定義する

Type

array

$__cache

$__cache : boolean

何度も同じ条件で取得しないようにキャッシュする

Type

boolean

Methods

setup()

setup(\Model  $model, array  $settings = array()) : void

setup

サンプルコード

Model
App::uses('BlockSettingBehavior', 'Blocks.Model/Behavior');

public $actsAs = array(
'Blocks.BlockSetting' => array(
    BlockSettingBehavior::USE_WORKFLOW,
    BlockSettingBehavior::USE_LIKE,
    BlockSettingBehavior::USE_UNLIKE,
    BlockSettingBehavior::USE_COMMENT,
    BlockSettingBehavior::USE_COMMENT_APPROVAL,
    'auto_play',
),
),

Parameters

\Model $model

モデル

array $settings

設定値

beforeValidate()

beforeValidate(\Model  $model, array  $options = array()) : mixed

beforeValidate

Parameters

\Model $model

Model using this behavior

array $options

Options passed from Model::save().

Returns

mixed —

False or null will abort the operation. Any other result will continue.

beforeSave()

beforeSave(\Model  $model, array  $options = array()) : mixed

beforeSave

Parameters

\Model $model

Model using this behavior

array $options

Options passed from Model::save().

Returns

mixed —

False if the operation should abort. Any other result will continue.

createBlockSetting()

createBlockSetting(\Model  $model, integer  $roomId = null, boolean  $isRow = false) : array

BlockSettingデータ新規作成

Parameters

\Model $model

モデル

integer $roomId

ルームID

boolean $isRow

縦持ちデータ取得するか

Returns

array

getBlockSetting()

getBlockSetting(\Model  $model, string  $blockKey = null, integer  $roomId = null, boolean  $isRow = false) : array

BlockSettingデータ取得

Parameters

\Model $model

モデル

string $blockKey

ブロックキー

integer $roomId

ルームID

boolean $isRow

縦持ちデータ取得するか

Returns

array

isExsistBlockSetting()

isExsistBlockSetting(\Model  $model, string  $blockKey = null, integer  $roomId = null) : boolean

BlockSettingデータ存在するか

Parameters

\Model $model

モデル

string $blockKey

ブロックキー

integer $roomId

ルームID

Returns

boolean

saveBlockSetting()

saveBlockSetting(\Model  $model, string  $blockKey = null, integer  $roomId = null) : mixed

BlockSettingデータ保存

仕組み

各プラグインの[横]の入力値を、BlockSettingをブロックキーで検索した縦データにセット or データなしなら、新規作成データが取得できるので、ブロックキーをセット して、縦データをsaveManyでまとめて保存します。

//(例)各プラグインのBlockSettingControllerからの登録処理 [横]データ
array(
    'VideoSetting' => array(
        'use_comment' => '1',
        'use_like' => '1',
        'use_unlike' => '0',
        'auto_play' => '0',
        'use_comment' => '1',
    )
)
↓
↓ ブロックキーで検索した[縦]データにセット
↓
array(
    'use_comment' => array(
        'id' => '1',        // 新規登録時はidない
        'plugin_key' => 'videos',
        'room_id' => '2',
        'block_key' => '2e86eb72e9cbd0ffa87ea23c81d4e3b7',
        'field_name' => 'use_comment',
        'value' => '1',
        'type' => 'boolean',
    ),
    'use_like' => array(
        'id' => '1',
        'plugin_key' => 'videos',
        'room_id' => '2',
        'block_key' => '2e86eb72e9cbd0ffa87ea23c81d4e3b7',
        'field_name' => 'use_like',
        'value' => '1',
        'type' => 'boolean',
    ),
    'use_unlike' => array(
        'id' => '1',
        'plugin_key' => 'videos',
        'room_id' => '2',
        'block_key' => '2e86eb72e9cbd0ffa87ea23c81d4e3b7',
        'field_name' => 'use_unlike',
        'value' => '0',
        'type' => 'boolean',
    ),
    'is_auto_play' => array(
        'id' => '1',
        'plugin_key' => 'videos',
        'room_id' => '2',
        'block_key' => '2e86eb72e9cbd0ffa87ea23c81d4e3b7',
        'field_name' => 'auto_play',
        'value' => '0',
        'type' => 'boolean',
    ),
)

Parameters

\Model $model

モデル

string $blockKey

ブロックキー

integer $roomId

ルームID

Throws

\InternalErrorException

Returns

mixed —

On success Model::$data if its not empty or true, false on failure

validateBlockSetting()

validateBlockSetting(\Model  $model, string  $blockKey = null) : boolean

ブロックセッティングのValidate追加処理

Parameters

\Model $model

モデル

string $blockKey

ブロックキー

Returns

boolean

_getFields()

_getFields(\Model  $model) : array

フィールド取得

Parameters

\Model $model

モデル

Returns

array —

フィールド

_getPluginKey()

_getPluginKey(\Model  $model) : string

プラグインキー取得

Parameters

\Model $model

モデル

Returns

string —

プラグインキー

_getDefaultApproval()

_getDefaultApproval(\Model  $model, array  $blockSettings, string  $fieldName, integer  $create) : array

use_workflow, use_comment_approvalの初期値取得 room.need_approvalによって、値変わる

Parameters

\Model $model

モデル

array $blockSettings

ブロックセッティングデータ

string $fieldName

フィールド名

integer $create

新規作成フラグ 0:更新、1:新規作成

Returns

array —

ブロックセッティングデータ

_convertColAndRow()

_convertColAndRow(\Model  $model, array  $blockSettings, boolean  $isRow) : array

横持ち、縦持ちにデータ変換

Parameters

\Model $model

モデル

array $blockSettings

ブロックセッティングデータ

boolean $isRow

縦持ちデータ取得するか

Returns

array

__findBlockSetting()

__findBlockSetting(\Model  $model, array  $conditions) : array

BlockSettingのデータ取得

Parameters

\Model $model

モデル

array $conditions

条件

Returns

array —

ブロックセッティングデータ