NAME_LENGTH
NAME_LENGTH = 255 : integer
Max length of content
名称が長い場合に切り取る文字数
Block Behavior
ブロックモデルにアソシエーションがあるモデルのビヘイビアです。
ブロックデータの内、ブロック編集にかかわる項目(名称、公開期限)を処理します。
ブロック名称フィールドを指定すると、ブロックモデルの名称として登録されます。
お知らせなど名称がない場合でも名称となり得るフィールドを指定してください。
NAME_LENGTHの長さで登録されます。
他にアソシエーションがあるモデルがある場合は、loadModelsに指定してください。
ブロックデータ登録後、指定されたモデルのblock_id、block_keyに値がセットされます。
ブロック削除時には指定されたモデルから削除されます。
public $actsAs = array(
'Blocks.Block' => array(
'name' => 'Faq.name',
'loadModels' => array(
'Category' => 'Categories.Category',
'CategoryOrder' => 'Categories.CategoryOrder',
'WorkflowComment' => 'Workflow.WorkflowComment',
)
)
)
ブロックデータを取得する場合の条件
getBlockConditions
getBlockConditionById
登録時は自動的に登録しますが、削除は明示的に呼び出してください。
deleteBlock
beforeValidate(\Model $model, array $options = array()) : mixed
beforeValidate is called before a model is validated, you can use this callback to add behavior validation rules into a models validate array. Returning false will allow you to make the validation fail.
\Model | $model | ビヘイビアの呼び出しのモデル |
array | $options | Options passed from Model::save(). |
False or null will abort the operation. Any other result will continue.
beforeSave(\Model $model, array $options = array()) : mixed
beforeSave is called before a model is saved. Returning false from a beforeSave callback will abort the save operation.
\Model | $model | ビヘイビアの呼び出しのモデル |
array | $options | Options passed from Model::save(). |
False if the operation should abort. Any other result will continue.
getBlockConditions(\Model $model, array $conditions = array()) : array
ブロック一覧データを取得する場合の条件を返します。
$this->Paginator->settings = array(
'Faq' => array(
'order' => array('Block.id' => 'desc'),
'conditions' => $this->Faq->getBlockConditions(),
)
);
\Model | $model | ビヘイビアの呼び出しのモデル |
array | $conditions | Model::find conditions default value |
Conditions data
getBlockIndexSettings(\Model $model, array $options = array()) : array
ブロック一覧データを取得するsettingsを返す。
$this->Paginator->settings = array(
'Faq' => $this->Faq->getBlockIndexSettings();
\Model | $model | ビヘイビアの呼び出しのモデル |
array | $options | Model::find conditions default value |
Conditions data
getBlockConditionById(\Model $model, array $conditions = array()) : array
ブロックデータを取得する場合の条件を返します。
$faq = $this->find('all', array(
'recursive' => -1,
'conditions' => $this->getBlockConditionById(),
));
\Model | $model | ビヘイビアの呼び出しのモデル |
array | $conditions | Model::find conditions default value |
Conditions data
deleteBlock(\Model $model, string $blockKey) : boolean
ブロックデータを削除します。.
public function deleteFaq($data) {
$this->begin();
try {
if (!$this->delete($data[Faq][id])) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}
$this->deleteBlock($data['Block']['key']);
$this->commit();
} catch (Exception $ex) {
$this->rollback($ex);
}
}
\Model | $model | ビヘイビアの呼び出しのモデル |
string | $blockKey | blocks.key |
成否