本文整理汇总了PHP中modMediaSource::updateObject方法的典型用法代码示例。如果您正苦于以下问题:PHP modMediaSource::updateObject方法的具体用法?PHP modMediaSource::updateObject怎么用?PHP modMediaSource::updateObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类modMediaSource
的用法示例。
在下文中一共展示了modMediaSource::updateObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
public function process()
{
/* get base paths and sanitize incoming paths */
$filePath = rawurldecode($this->getProperty('file', ''));
$loaded = $this->getSource();
if (!$this->source instanceof modMediaSource) {
return $loaded;
}
$path = $this->source->updateObject($filePath, $this->getProperty('content'));
if (empty($path)) {
$msg = '';
$errors = $this->source->getErrors();
foreach ($errors as $k => $msg) {
$this->addFieldError($k, $msg);
}
return $this->failure($msg);
}
return $this->success('', array('file' => $path));
}
示例2: Resize
/**
* @param array $options
* @param null $raw
*
* @return bool|string
*/
public function Resize(array $options, $raw = null)
{
if ($this->get('type') != 'image') {
return false;
} elseif (!($raw = $this->_phpThumb($options, $raw))) {
return false;
}
$filename = $this->get('path') . $this->get('file');
if ($this->prepareSource()) {
$this->mediaSource->updateObject($filename, $raw);
if (empty($this->mediaSource->errors['file'])) {
$this->set('size', strlen($raw));
$this->save();
return $this->mediaSource->getObjectUrl($filename);
} else {
$this->xpdo->log(modX::LOG_LEVEL_ERROR, "Could not update file {$filename}: " . $this->mediaSource->errors['file']);
}
}
return false;
}