本文整理汇总了PHP中TYPO3\CMS\Core\Resource\File::setIndexingInProgess方法的典型用法代码示例。如果您正苦于以下问题:PHP File::setIndexingInProgess方法的具体用法?PHP File::setIndexingInProgess怎么用?PHP File::setIndexingInProgess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Resource\File
的用法示例。
在下文中一共展示了File::setIndexingInProgess方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexFile
/**
* Creates or updates a file index entry from a file object.
*
* @param File $fileObject
* @param bool $updateObject Set this to FALSE to get the indexed values. You have to take care of updating the object yourself then!
* @return File|array the indexed $fileObject or an array of indexed properties.
* @throws \RuntimeException
*/
public function indexFile(File $fileObject, $updateObject = TRUE)
{
$fileObject->setIndexingInProgess(TRUE);
// Get the file information of this object
$fileInfo = $this->gatherFileInformation($fileObject);
// Signal slot BEFORE the file was indexed
$this->emitPreFileIndexSignal($fileObject, $fileInfo);
// If the file is already indexed, then the file information will
// be updated on the existing record
if ($fileObject->isIndexed()) {
$fileInfo['missing'] = 0;
$fileObject->updateProperties($fileInfo);
$this->getFileIndexRepository()->update($fileObject);
} else {
// Check if a file has been moved outside of FAL -- we have some
// orphaned index record in this case we could update
$resultRows = $this->getFileIndexRepository()->findByContentHash($fileInfo['sha1']);
$otherFiles = array();
foreach ($resultRows as $row) {
$otherFiles[] = $this->getFactory()->getFileObject($row['uid'], $row);
}
$movedFile = FALSE;
/** @var $otherFile File */
foreach ($otherFiles as $otherFile) {
if (!$otherFile->exists()) {
// @todo: create a log entry
$movedFile = TRUE;
$fileInfo['missing'] = 0;
$otherFile->updateProperties($fileInfo);
$this->getFileIndexRepository()->update($otherFile);
$fileInfo['uid'] = $otherFile->getUid();
$fileObject = $otherFile;
// Skip the rest of the files here as we might have more files that are missing, but we can only
// have one entry. The optimal solution would be to merge these records then, but this requires
// some more advanced logic that we currently have not implemented.
break;
}
}
// File was not moved, so it is a new index record
if ($movedFile === FALSE) {
// Crdate and tstamp should not be present when updating
// the file object, as they only relate to the index record
$additionalInfo = array('crdate' => $GLOBALS['EXEC_TIME'], 'tstamp' => $GLOBALS['EXEC_TIME']);
if (isset($GLOBALS['BE_USER']->user['uid'])) {
$additionalInfo['cruser_id'] = (int) $GLOBALS['BE_USER']->user['uid'];
}
$indexRecord = array_merge($fileInfo, $additionalInfo);
$fileObject->updateProperties($indexRecord);
$this->getFileIndexRepository()->add($fileObject);
}
}
// Check for an error during the execution and throw an exception
$error = $GLOBALS['TYPO3_DB']->sql_error();
if ($error) {
throw new \RuntimeException('Error during file indexing: "' . $error . '"', 1314455642);
}
if ($fileInfo['type'] == $fileObject::FILETYPE_IMAGE) {
$rawFileLocation = $fileObject->getForLocalProcessing(FALSE);
$metaData = array();
$imageSize = getimagesize($rawFileLocation);
if ($imageSize === FALSE) {
$metaData['width'] = 0;
$metaData['height'] = 0;
} else {
list($metaData['width'], $metaData['height']) = $imageSize;
}
$this->getMetaDataRepository()->update($fileObject->getUid(), $metaData);
}
// Signal slot AFTER the file was indexed
$this->emitPostFileIndexSignal($fileObject, $fileInfo);
$fileObject->setIndexingInProgess(FALSE);
if ($updateObject) {
return $fileObject;
} else {
return $fileInfo;
}
}