本文整理汇总了PHP中Control::prepareUserValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Control::prepareUserValue方法的具体用法?PHP Control::prepareUserValue怎么用?PHP Control::prepareUserValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Control
的用法示例。
在下文中一共展示了Control::prepareUserValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareUserValue
public function prepareUserValue($value, $getValue = null)
{
if (empty($value)) {
$value = null;
}
return parent::prepareUserValue($value, $getValue);
}
示例2: prepareUserValue
public function prepareUserValue($value, $getValue = null)
{
if (empty($this->images) || empty($this->imageSaveHandler)) {
return parent::prepareUserValue($value, $getValue);
}
$value = preg_replace_callback('/(<img.*?src=\\s*([\'"]))(.*?)(\\2)/is', function ($matches) use($getValue) {
if (preg_match('/^blob:http.*?#(.+)$/i', $matches[3], $urls)) {
$relation = call_user_func($getValue->relation, $this->images);
$file = $this->normalizeImageExtension($this->getFilePath($urls[1]));
$value = call_user_func($this->imageSaveHandler, ['file' => $file], $relation->getRelated(), $getValue);
if ($value) {
$this->relatedData[] = ['relation' => $relation, 'value' => $value];
return $matches[1] . htmlentities($value->url) . $matches[4];
}
}
return $matches[0];
}, $value);
parent::prepareUserValue($value, $getValue);
}
示例3: prepareUserValue
public function prepareUserValue($value, $getValue = null)
{
if (is_array($value)) {
$value = array_shift($value);
}
if (empty($value)) {
foreach ($this->copy as $field) {
$parentValue = call_user_func($getValue->field, $field);
if (is_array($parentValue)) {
$parentValue = array_shift($parentValue);
}
if (!empty($parentValue) && isset($parentValue['file'])) {
$value = $parentValue;
break;
}
}
}
if (!empty($value)) {
if (isset($value['file'])) {
// если указан файл - это новая картинка, загружаем
$value['file'] = $this->normalizeImageExtension($this->getFilePath($value['file']));
foreach ($this->images as $image) {
$image->setUserValue($this->prepareUserSaveValue($value, $image->getName(), $getValue));
}
return parent::prepareUserValue($value, $getValue);
}
// если файл не указан, значит нужно обновить данные уже подцепленной картинки
foreach ($this->images as $image) {
$relation = call_user_func($getValue->relation, $image->getName());
$image->setUserValue($relation->first());
}
$relation = call_user_func($getValue->relation, $this->getName());
return $this->setUserValue($relation->first());
}
return $this;
}