本文整理匯總了PHP中FilesModel::findOneByUuid方法的典型用法代碼示例。如果您正苦於以下問題:PHP FilesModel::findOneByUuid方法的具體用法?PHP FilesModel::findOneByUuid怎麽用?PHP FilesModel::findOneByUuid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類FilesModel
的用法示例。
在下文中一共展示了FilesModel::findOneByUuid方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: saveCbValidateFilePrefix
/**
* @param $strPrefix
* @param \Contao\DataContainer $dc
* @return string
*/
public function saveCbValidateFilePrefix($strPrefix, \Contao\DataContainer $dc)
{
$i = 0;
if ($strPrefix != '') {
// >= php ver 5.4
$transliterator = Transliterator::createFromRules(':: NFD; :: [:Nonspacing Mark:] Remove; :: NFC;', Transliterator::FORWARD);
$strPrefix = $transliterator->transliterate($strPrefix);
$strPrefix = str_replace('.', '_', $strPrefix);
$arrOptions = array('column' => array('tl_gallery_creator_pictures.pid=?'), 'value' => array($dc->id), 'order' => 'sorting ASC');
$objPicture = MCupic\GalleryCreatorPicturesModel::findAll($arrOptions);
if ($objPicture !== null) {
while ($objPicture->next()) {
$objFile = \FilesModel::findOneByUuid($objPicture->uuid);
if ($objFile !== null) {
if (is_file(TL_ROOT . '/' . $objFile->path)) {
$oFile = new File($objFile->path);
$i++;
while (is_file($oFile->dirname . '/' . $strPrefix . '_' . $i . '.' . strtolower($oFile->extension))) {
$i++;
}
$oldPath = $oFile->dirname . '/' . $strPrefix . '_' . $i . '.' . strtolower($oFile->extension);
$newPath = str_replace(TL_ROOT . '/', '', $oldPath);
// rename file
if ($oFile->renameTo($newPath)) {
$objPicture->path = $oFile->path;
$objPicture->save();
\Message::addInfo(sprintf('Picture with ID %s has been renamed to %s.', $objPicture->id, $newPath));
}
}
}
}
}
}
return '';
}