本文整理汇总了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 '';
}