本文整理汇总了PHP中ActiveRecordModel::loadRequestData方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecordModel::loadRequestData方法的具体用法?PHP ActiveRecordModel::loadRequestData怎么用?PHP ActiveRecordModel::loadRequestData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActiveRecordModel
的用法示例。
在下文中一共展示了ActiveRecordModel::loadRequestData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
protected function save(ActiveRecordModel $listGroup)
{
$validator = $this->buildValidator();
if ($validator->isValid()) {
$listGroup->loadRequestData($this->request);
$listGroup->save();
return new JSONResponse(array('ID' => $listGroup->getID(), 'data' => $listGroup->toArray()), 'success');
} else {
return new JSONResponse(array('errors' => $validator->getErrorList()), 'failure');
}
}
示例2: loadRequestData
public function loadRequestData(Request $request)
{
if (!$request->get('password')) {
$request->remove('password');
}
return parent::loadRequestData($request);
}
示例3: loadRequestData
public function loadRequestData(Request $request, $prefix = '')
{
parent::loadRequestData($request, $prefix);
if ($request->get($prefix . 'stateID')) {
$this->state->set(State::getInstanceByID((int) $request->get($prefix . 'stateID'), true));
$this->stateName->set(null);
} else {
if ($request->isValueSet($prefix . 'stateName')) {
$this->stateName->set($request->get($prefix . 'stateName'));
$this->state->set(null);
}
}
}
示例4: importAttributes
protected function importAttributes(ActiveRecordModel $instance, $record, $fields, $attrIdentifier = 'eavField')
{
if (isset($fields[$attrIdentifier])) {
$impReq = new Request();
$fieldClass = ucfirst($attrIdentifier);
$valueClass = 'eavField' == $attrIdentifier ? 'EavValue' : $fieldClass . 'Value';
foreach ($fields[$attrIdentifier] as $specFieldID => $csvIndex) {
if (empty($record[$csvIndex])) {
continue;
}
$attr = ActiveRecordModel::getInstanceByID($fieldClass, $specFieldID, ActiveRecord::LOAD_DATA);
if ($attr->isSimpleNumbers()) {
$impReq->set($attr->getFormFieldName(), (double) $record[$csvIndex]);
} else {
if ($attr->isSelector()) {
if ($attr->isMultiValue->get()) {
$values = explode(',', $record[$csvIndex]);
} else {
$values = array($record[$csvIndex]);
}
foreach ($values as $fieldValue) {
$fieldValue = trim($fieldValue);
$f = new ARSelectFilter(new LikeCond(MultilingualObject::getLangSearchHandle(new ARFieldHandle($valueClass, 'value'), $this->application->getDefaultLanguageCode()), $fieldValue . '%'));
$f->setLimit(1);
if (!($value = $attr->getRelatedRecordSet($valueClass, $f)->shift())) {
$value = call_user_func_array(array($valueClass, 'getNewInstance'), array($attr));
if ($attr->type->get() == EavFieldCommon::TYPE_NUMBERS_SELECTOR) {
$value->value->set($fieldValue);
} else {
$value->setValueByLang('value', $this->application->getDefaultLanguageCode(), $fieldValue);
}
$value->save();
}
if (!$attr->isMultiValue->get()) {
$impReq->set($attr->getFormFieldName(), $value->getID());
} else {
$impReq->set($value->getFormFieldName(), true);
}
}
} else {
$impReq->set($attr->getFormFieldName(), $record[$csvIndex]);
}
}
}
$instance->loadRequestData($impReq);
$instance->save();
}
}