本文整理汇总了PHP中TYPO3\CMS\Core\Resource\ResourceStorage::hasFile方法的典型用法代码示例。如果您正苦于以下问题:PHP ResourceStorage::hasFile方法的具体用法?PHP ResourceStorage::hasFile怎么用?PHP ResourceStorage::hasFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Resource\ResourceStorage
的用法示例。
在下文中一共展示了ResourceStorage::hasFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processChangedAndNewFiles
/**
* Processes the Files which have been detected as "changed or new"
* in the storage
*
* @return void
*/
protected function processChangedAndNewFiles()
{
foreach ($this->filesToUpdate as $identifier => $data) {
if ($data == NULL) {
// search for files with same content hash in indexed storage
$fileHash = $this->storage->hashFileByIdentifier($identifier, 'sha1');
$files = $this->getFileIndexRepository()->findByContentHash($fileHash);
$fileObject = NULL;
if (!empty($files)) {
foreach ($files as $fileIndexEntry) {
// check if file is missing then we assume it's moved/renamed
if (!$this->storage->hasFile($fileIndexEntry['identifier'])) {
$fileObject = $this->getResourceFactory()->getFileObject($fileIndexEntry['uid'], $fileIndexEntry);
$fileObject->updateProperties(array('identifier' => $identifier));
$this->updateIndexEntry($fileObject);
$this->identifiedFileUids[] = $fileObject->getUid();
break;
}
}
}
// create new index when no missing file with same content hash is found
if ($fileObject === NULL) {
$fileObject = $this->createIndexEntry($identifier);
$this->identifiedFileUids[] = $fileObject->getUid();
}
} else {
// update existing file
$fileObject = $this->getResourceFactory()->getFileObject($data['uid'], $data);
$this->updateIndexEntry($fileObject);
}
}
}
示例2: exists
/**
* Checks if this file exists. This should normally always return TRUE;
* it might only return FALSE when this object has been created from an
* index record without checking for.
*
* @return boolean TRUE if this file physically exists
*/
public function exists()
{
if ($this->deleted) {
return FALSE;
}
return $this->storage->hasFile($this->getIdentifier());
}
示例3: detectMissingFiles
/**
* Since by now all files in filesystem have been looked at it is save to assume,
* that files that are in indexed but not touched in this run are missing
*/
protected function detectMissingFiles()
{
$indexedNotExistentFiles = $this->getFileIndexRepository()->findInStorageAndNotInUidList($this->storage, $this->identifiedFileUids);
foreach ($indexedNotExistentFiles as $record) {
if (!$this->storage->hasFile($record['identifier'])) {
$this->getFileIndexRepository()->markFileAsMissing($record['uid']);
}
}
}
示例4: findByStorageAndIdentifier
/**
* @param ResourceStorage $storage
* @param string $identifier
*
* @return null|ProcessedFile
*/
public function findByStorageAndIdentifier(ResourceStorage $storage, $identifier)
{
$processedFileObject = null;
if ($storage->hasFile($identifier)) {
$databaseRow = $this->databaseConnection->exec_SELECTgetSingleRow('*', $this->table, 'storage = ' . (int) $storage->getUid() . ' AND identifier = ' . $this->databaseConnection->fullQuoteStr($identifier, $this->table));
if ($databaseRow) {
$processedFileObject = $this->createDomainObject($databaseRow);
}
}
return $processedFileObject;
}
示例5: findByStorageAndIdentifier
/**
* @param ResourceStorage $storage
* @param string $identifier
*
* @return null|ProcessedFile
*/
public function findByStorageAndIdentifier(ResourceStorage $storage, $identifier)
{
$processedFileObject = null;
if ($storage->hasFile($identifier)) {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($this->table);
$databaseRow = $queryBuilder->select('*')->from($this->table)->where($queryBuilder->expr()->eq('storage', $queryBuilder->createNamedParameter($storage->getUid(), \PDO::PARAM_INT)), $queryBuilder->expr()->eq('identifier', $queryBuilder->createNamedParameter($identifier, \PDO::PARAM_STR)))->execute()->fetch();
if ($databaseRow) {
$processedFileObject = $this->createDomainObject($databaseRow);
}
}
return $processedFileObject;
}