本文整理匯總了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;
}