本文整理匯總了PHP中Cake\ORM\RulesChecker::addCreate方法的典型用法代碼示例。如果您正苦於以下問題:PHP RulesChecker::addCreate方法的具體用法?PHP RulesChecker::addCreate怎麽用?PHP RulesChecker::addCreate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Cake\ORM\RulesChecker
的用法示例。
在下文中一共展示了RulesChecker::addCreate方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: buildRules
public function buildRules(RulesChecker $rules)
{
$rules->add($rules->existsIn('character_id', 'characters'));
$rules->add($rules->existsIn('skill_id', 'skills'));
$rules->addCreate([$this, 'addRelations']);
$rules->addCreate([$this, 'disallowDeprecated']);
$rules->addCreate([$this, 'hasXPAvailable']);
return $rules;
}
示例2: buildRules
/**
* Application rules.
*
* @param \Cake\ORM\RulesChecker $rules The rule checker
* @return \Cake\ORM\RulesChecker
*/
public function buildRules(RulesChecker $rules)
{
// check max instances limit
$rules->addCreate(function ($instance, $options) {
$info = (array) $instance->info();
if (isset($info['maxInstances']) && $info['maxInstances'] > 0) {
if (!$instance->get('eav_attribute')) {
return false;
}
$count = $this->find()->select(['FieldInstances.id', 'FieldInstances.handler', 'EavAttribute.id', 'EavAttribute.table_alias'])->contain(['EavAttribute'])->where(['EavAttribute.table_alias' => $instance->get('eav_attribute')->get('table_alias'), 'FieldInstances.handler' => $instance->get('handler')])->count();
return $count <= intval($info['maxInstances']) - 1;
}
return true;
}, 'maxInstances', ['errorField' => 'label', 'message' => __d('field', 'No more instances of this field can be attached, limit reached.')]);
return $rules;
}
示例3: buildRules
/**
*
* @param RulesChecker $rules
*/
public function buildRules(RulesChecker $rules)
{
$rules->addCreate($rules->isUnique(['name']), 'uniqueName', ['message' => 'Już istnieje taka rola']);
return $rules;
}