当前位置: 首页>>代码示例>>PHP>>正文


PHP File::setIndexingInProgess方法代码示例

本文整理汇总了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;
     }
 }
开发者ID:khanhdeux,项目名称:typo3test,代码行数:85,代码来源:IndexerService.php


注:本文中的TYPO3\CMS\Core\Resource\File::setIndexingInProgess方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。