本文整理汇总了PHP中Set::Merge方法的典型用法代码示例。如果您正苦于以下问题:PHP Set::Merge方法的具体用法?PHP Set::Merge怎么用?PHP Set::Merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Set
的用法示例。
在下文中一共展示了Set::Merge方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeSave
/**
* Upload the latest version of a file before saving the upload record (or potentially the first/only version)
*/
public function beforeSave()
{
if (!isset($this->data['Upload']['id'])) {
$this->data['UploadVersion']['upload_id'] = null;
} else {
$this->data['UploadVersion']['upload_id'] = $this->data['Upload']['id'];
}
// Save just the uploadversion
$data['UploadVersion'] = $this->data['UploadVersion'];
if (!$this->UploadVersion->save($data)) {
$this->validationErrors = Set::Merge($this->validationErrors, $this->UploadVersion->validationErrors);
return;
}
$this->data['Upload']['active_version_id'] = $this->UploadVersion->id;
// First version
if (empty($this->data['Upload']['id'])) {
$this->__firstVersion = true;
}
return true;
}
示例2: _getClass
function _getClass($type, $name)
{
$_this =& ClassCollection::getInstance();
$options = $_this->getOption($type, $name);
$res = array('class' => null, 'import' => array(), 'isParent' => false);
if (!empty($options['parent'])) {
$inerit = array_intersect_key($options, array_flip($_this->parentInerit));
$parentOpt = Set::Merge($inerit, $options['parent']);
$parent = $_this->_getClass(null, $parentOpt);
if (empty($parent)) {
return null;
} else {
$res['import'] = $parent['import'];
}
}
$importOpt = $_this->parseImportOption($options);
foreach ($importOpt['search'] as $plugin => $search) {
foreach ($search as $path) {
$iopt = $importOpt;
$iopt['search'] = $path;
if (App::import($iopt)) {
$res['import'][] = $iopt;
$res['class'] = $iopt['name'];
$res['plugin'] = $plugin == 'app' ? null : $plugin;
break 2;
}
}
}
if (!$res['class']) {
if (!empty($parent) && $options['defaultByParent']) {
$res['isParent'] = true;
$res['class'] = $parent['class'];
$res['plugin'] = $parent['plugin'];
} elseif ($options['throwException']) {
return array('error' => array('%name% not found.', array('%name%' => $importOpt['name'])));
} else {
return null;
}
}
return $res;
}
示例3: getClass
function getClass($type, $name, &$isParent = false)
{
$_this =& ClassCollection::getInstance();
$options = $_this->getOption($type, $name);
if (!empty($options['parent'])) {
$inerit = array_intersect_key($options, array_flip($_this->parentInerit));
$parentOpt = Set::Merge($inerit, $options['parent']);
$parent = $_this->getClass(null, $parentOpt);
if (empty($parent)) {
return null;
}
}
$importOpt = $_this->parseImportOption($options);
//debug($importOpt);
if (App::import($importOpt)) {
return $importOpt['name'];
} else {
if (!empty($parent) && $options['defaultByParent']) {
$isParent = true;
return $parent;
}
if ($options['throwException']) {
debug($importOpt['name'] . ' not found.');
}
return null;
}
}
示例4: textarea
/**
* This action simply creates a textarea with the 'markitup-editor' class
*/
function textarea($fieldName, $options = array())
{
$FormHelper = ClassRegistry::init('Form');
$options = Set::Merge($options, array('class' => 'markitup-editor'));
return $FormHelper->text($fieldName, $options);
}
示例5: _queueSkill
function _queueSkill($data = array())
{
if (!empty($data['skill_id']) && !empty($data['caster_id'])) {
$format = $this->Skill->SkillInstance->getDataSource()->columns['datetime']['format'];
$now = date($format);
//////// Get conflict SkillInstance ////////
$findOpt = array('conditions' => array('caster_id' => $data['caster_id'], 'or' => array('recovered_time >' => $now, array('skill_id' => $data['skill_id'], 'cooled_down_time > ' => $now))), 'order' => array('IF(`skill_id` = ' . $data['skill_id'] . ',cooled_down_time,recovered_time) DESC'));
$lastConflict = $this->Skill->SkillInstance->find('first', $findOpt);
//////// Create SkillInstance ////////
$allowed = array('skill_id', 'caster_id', 'main_target_id');
$inst = array_intersect_key($data, array_flip($allowed));
//debug($inst);
$start_time = $now;
if (!empty($lastConflict)) {
$inst['prev_id'] = $lastConflict['SkillInstance']['id'];
$afterCooldown = $lastConflict['SkillInstance']['skill_id'] == $data['skill_id'];
if ($afterCooldown) {
if (!empty($lastConflict['SkillInstance']['cooled_down_time'])) {
$start_time = $lastConflict['SkillInstance']['cooled_down_time'];
}
} else {
if (!empty($lastConflict['SkillInstance']['recovered_time'])) {
$start_time = $lastConflict['SkillInstance']['recovered_time'];
}
}
}
$this->Skill->SkillInstance->create();
$inst = $this->Skill->SkillInstance->save($inst);
if ($inst) {
$instance_id = $this->Skill->SkillInstance->id;
$inst = Set::Merge($inst, $this->Skill->SkillInstance->save(array('id' => $instance_id, 'start_time' => $start_time)));
if (!empty($lastConflict)) {
$lastData = array('id' => $lastConflict['SkillInstance']['id'], 'next_id' => $instance_id, 'next_need_cooldown' => $afterCooldown);
$this->Skill->SkillInstance->save($lastData);
}
if (!empty($inst['TimedEvent']['start_time']['TimedEvent']['id'])) {
$this->TimedEvent = ClassRegistry::init('TimedEvent');
$this->TimedEvent->checkEvents($inst['TimedEvent']['start_time']);
}
return $inst;
}
}
return null;
}