本文整理汇总了PHP中TYPO3\CMS\Core\Resource\ResourceStorage::getUid方法的典型用法代码示例。如果您正苦于以下问题:PHP ResourceStorage::getUid方法的具体用法?PHP ResourceStorage::getUid怎么用?PHP ResourceStorage::getUid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Resource\ResourceStorage
的用法示例。
在下文中一共展示了ResourceStorage::getUid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* @throws \PHPUnit_Framework_Exception
*/
protected function setUp()
{
$this->storageMock = $this->getMock(ResourceStorage::class, array(), array(), '', FALSE);
$this->storageMock->expects($this->any())->method('getUid')->will($this->returnValue(5));
$this->folderMock = $this->getMock(Folder::class, array(), array(), '', FALSE);
$this->folderMock->expects($this->any())->method('getStorage')->willReturn($this->storageMock);
$this->storageMock->expects($this->any())->method('getProcessingFolder')->willReturn($this->folderMock);
$this->databaseRow = array('uid' => '1234567', 'identifier' => 'dummy.txt', 'name' => $this->getUniqueId('dummy_'), 'storage' => $this->storageMock->getUid());
}
示例2: searchForDuplicateSha1
/**
* Return duplicates file records
*
* @param \TYPO3\CMS\Core\Resource\ResourceStorage $storage
* @return array
*/
public function searchForDuplicateSha1(ResourceStorage $storage)
{
// Detect duplicate records.
$query = "SELECT sha1 FROM sys_file WHERE storage = {$storage->getUid()} GROUP BY sha1, storage Having COUNT(*) > 1";
$resource = $this->getDatabaseConnection()->sql_query($query);
$duplicates = array();
while ($row = $this->getDatabaseConnection()->sql_fetch_assoc($resource)) {
$clause = sprintf('sha1 = "%s" AND storage = %s', $row['sha1'], $storage->getUid());
$records = $this->getDatabaseConnection()->exec_SELECTgetRows('*', 'sys_file', $clause);
$duplicates[$row['sha1']] = $records;
}
return $duplicates;
}
示例3: migrateRecord
/**
* Processes the actual transformation from CSV to sys_file_references
*
* @param array $record
* @return void
*/
protected function migrateRecord(array $record)
{
$collections = array();
if (trim($record['select_key'])) {
$GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_file_collection', array('pid' => $record['pid'], 'title' => $record['select_key'], 'storage' => $this->storage->getUid(), 'folder' => ltrim('fileadmin/', $record['select_key'])));
$collections[] = $GLOBALS['TYPO3_DB']->sql_insert_id();
}
$files = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $record['media'], TRUE);
$descriptions = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('
', $record['imagecaption']);
$titleText = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('
', $record['titleText']);
$i = 0;
foreach ($files as $file) {
if (file_exists(PATH_site . 'uploads/media/' . $file)) {
\TYPO3\CMS\Core\Utility\GeneralUtility::upload_copy_move(PATH_site . 'uploads/media/' . $file, $this->targetDirectory . $file);
$fileObject = $this->storage->getFile(self::FOLDER_ContentUploads . '/' . $file);
$this->fileRepository->addToIndex($fileObject);
$dataArray = array('uid_local' => $fileObject->getUid(), 'tablenames' => 'tt_content', 'uid_foreign' => $record['uid'], 'fieldname' => 'media', 'sorting_foreign' => $i);
if (isset($descriptions[$i])) {
$dataArray['description'] = $descriptions[$i];
}
if (isset($titleText[$i])) {
$dataArray['alternative'] = $titleText[$i];
}
$GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_file_reference', $dataArray);
unlink(PATH_site . 'uploads/media/' . $file);
}
$i++;
}
$this->cleanRecord($record, $i, $collections);
}
示例4: migrateRelativeFilemounts
/**
* Relative filemounts are transformed to relate to our fileadmin/ storage
* and their path is modified to be a valid resource location
*/
protected function migrateRelativeFilemounts()
{
$relativeFilemounts = $this->db->exec_SELECTgetRows('*', 'sys_filemounts', 'base = 1' . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('sys_filemounts'));
foreach ($relativeFilemounts as $filemount) {
$this->db->exec_UPDATEquery('sys_filemounts', 'uid=' . intval($filemount['uid']), array('base' => $this->storage->getUid(), 'path' => '/' . ltrim($filemount['path'], '/')));
$this->sqlQueries[] = $GLOBALS['TYPO3_DB']->debug_lastBuiltQuery;
}
}
示例5: getTotalNumberOfFiles
/**
* @return int
*/
public function getTotalNumberOfFiles()
{
$clause = 'storage > 0';
if ($this->storage) {
$clause = 'storage = ' . $this->storage->getUid();
}
$record = $this->getDatabaseConnection()->exec_SELECTgetSingleRow('count(*) AS totalNumberOfFiles', 'sys_file', $clause);
return (int) $record['totalNumberOfFiles'];
}
示例6: 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;
}
示例7: 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;
}
示例8: addFileMountsToStorage
/**
* Adds file mounts from the user's file mount records
*
* @param ResourceStorage $storage
* @return void
*/
protected function addFileMountsToStorage(ResourceStorage $storage)
{
foreach ($this->backendUserAuthentication->getFileMountRecords() as $fileMountRow) {
if ((int) $fileMountRow['base'] === (int) $storage->getUid()) {
try {
$storage->addFileMount($fileMountRow['path'], $fileMountRow);
} catch (FolderDoesNotExistException $e) {
// That file mount does not seem to be valid, fail silently
}
}
}
}
示例9: migrateRelativeFilemounts
/**
* Relative filemounts are transformed to relate to our fileadmin/ storage
* and their path is modified to be a valid resource location
*
* @return void
*/
protected function migrateRelativeFilemounts()
{
$relativeFilemounts = $this->db->exec_SELECTgetRows('*', 'sys_filemounts', 'base = 1' . BackendUtility::deleteClause('sys_filemounts'));
foreach ($relativeFilemounts as $filemount) {
$storagePath = trim($filemount['path'], '/') . '/';
if ($storagePath !== '/') {
$storagePath = '/' . $storagePath;
}
$this->db->exec_UPDATEquery('sys_filemounts', 'uid=' . (int) $filemount['uid'], array('base' => $this->storage->getUid(), 'path' => $storagePath));
$this->sqlQueries[] = $GLOBALS['TYPO3_DB']->debug_lastBuiltQuery;
}
}
示例10: detectChangedFilesInStorage
/**
* Adds updated files to the processing queue
*
* @param array $fileIdentifierArray
* @return void
*/
protected function detectChangedFilesInStorage(array $fileIdentifierArray)
{
foreach ($fileIdentifierArray as $fileIdentifier) {
// skip processed files
if ($this->storage->isWithinProcessingFolder($fileIdentifier)) {
continue;
}
// Get the modification time for file-identifier from the storage
$modificationTime = $this->storage->getFileInfoByIdentifier($fileIdentifier, array('mtime'));
// Look if the the modification time in FS is higher than the one in database (key needed on timestamps)
$indexRecord = $this->getFileIndexRepository()->findOneByStorageUidAndIdentifier($this->storage->getUid(), $fileIdentifier);
if ($indexRecord !== FALSE) {
$this->identifiedFileUids[] = $indexRecord['uid'];
if ($indexRecord['modification_date'] < $modificationTime['mtime'] || $indexRecord['missing']) {
$this->filesToUpdate[$fileIdentifier] = $indexRecord;
}
} else {
$this->filesToUpdate[$fileIdentifier] = NULL;
}
}
}
示例11: updateFile
/**
* Updates the properties of a file object with some that are freshly
* fetched from the driver.
*
* @param \TYPO3\CMS\Core\Resource\AbstractFile $file
* @param string $identifier The identifier of the file. If set, this will overwrite the file object's identifier (use e.g. after moving a file)
* @param \TYPO3\CMS\Core\Resource\ResourceStorage $storage
* @return void
*/
protected function updateFile(\TYPO3\CMS\Core\Resource\AbstractFile $file, $identifier = '', $storage = NULL)
{
if ($identifier === '') {
$identifier = $file->getIdentifier();
}
$fileInfo = $this->driver->getFileInfoByIdentifier($identifier);
// TODO extend mapping
$newProperties = array('storage' => $fileInfo['storage'], 'identifier' => $fileInfo['identifier'], 'tstamp' => $fileInfo['mtime'], 'crdate' => $fileInfo['ctime'], 'mime_type' => $fileInfo['mimetype'], 'size' => $fileInfo['size'], 'name' => $fileInfo['name']);
if ($storage !== NULL) {
$newProperties['storage'] = $storage->getUid();
}
$file->updateProperties($newProperties);
/** @var $fileRepository \TYPO3\CMS\Core\Resource\FileRepository */
$fileRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository');
$fileRepository->update($file);
}
示例12: getFilePermissionsForStorage
/**
* Gets the file permissions for a storage
* by merging any storage-specific permissions for a
* storage with the default settings.
* Admin users will always get the default settings.
*
* @api
* @param \TYPO3\CMS\Core\Resource\ResourceStorage $storageObject
* @return array
*/
public function getFilePermissionsForStorage(\TYPO3\CMS\Core\Resource\ResourceStorage $storageObject)
{
$finalUserPermissions = $this->getFilePermissions();
if (!$this->isAdmin()) {
$storageFilePermissions = $this->getTSConfigProp('permissions.file.storage.' . $storageObject->getUid());
if (!empty($storageFilePermissions)) {
array_walk($storageFilePermissions, function ($value, $permission) use(&$finalUserPermissions) {
$finalUserPermissions[$permission] = (bool) $value;
});
}
}
return $finalUserPermissions;
}
示例13: getShortHashNumberForStorage
/**
* Helper method to map md5-hash to shorter number
*
* @param \TYPO3\CMS\Core\Resource\ResourceStorage $storageObject
* @param \TYPO3\CMS\Core\Resource\Folder $startingPointFolder
* @return int
*/
protected function getShortHashNumberForStorage(\TYPO3\CMS\Core\Resource\ResourceStorage $storageObject = NULL, \TYPO3\CMS\Core\Resource\Folder $startingPointFolder = NULL)
{
if (!$this->storageHashNumbers) {
$this->storageHashNumbers = array();
// Mapping md5-hash to shorter number:
$hashMap = array();
foreach ($this->storages as $storageUid => $storage) {
$fileMounts = $storage->getFileMounts();
if (count($fileMounts)) {
foreach ($fileMounts as $fileMount) {
$nkey = hexdec(substr(GeneralUtility::md5int($fileMount['folder']->getCombinedIdentifier()), 0, 4));
$this->storageHashNumbers[$storageUid . $fileMount['folder']->getCombinedIdentifier()] = $nkey;
}
} else {
$folder = $storage->getRootLevelFolder();
$nkey = hexdec(substr(GeneralUtility::md5int($folder->getCombinedIdentifier()), 0, 4));
$this->storageHashNumbers[$storageUid . $folder->getCombinedIdentifier()] = $nkey;
}
}
}
if ($storageObject) {
if ($startingPointFolder) {
return $this->storageHashNumbers[$storageObject->getUid() . $startingPointFolder->getCombinedIdentifier()];
} else {
return $this->storageHashNumbers[$storageObject->getUid()];
}
} else {
return NULL;
}
}
示例14: getShortHashNumberForStorage
/**
* Helper method to map md5-hash to shorter number
*
* @param ResourceStorage $storageObject
* @param Folder $startingPointFolder
*
* @return int
*/
protected function getShortHashNumberForStorage(ResourceStorage $storageObject = null, Folder $startingPointFolder = null)
{
if (!$this->storageHashNumbers) {
$this->storageHashNumbers = [];
foreach ($this->storages as $storageUid => $storage) {
$fileMounts = $storage->getFileMounts();
if (!empty($fileMounts)) {
foreach ($fileMounts as $fileMount) {
$nkey = hexdec(substr(GeneralUtility::md5int($fileMount['folder']->getCombinedIdentifier()), 0, 4));
$this->storageHashNumbers[$storageUid . $fileMount['folder']->getCombinedIdentifier()] = $nkey;
}
} else {
$folder = $storage->getRootLevelFolder();
$nkey = hexdec(substr(GeneralUtility::md5int($folder->getCombinedIdentifier()), 0, 4));
$this->storageHashNumbers[$storageUid . $folder->getCombinedIdentifier()] = $nkey;
}
}
}
if ($storageObject) {
if ($startingPointFolder) {
return $this->storageHashNumbers[$storageObject->getUid() . $startingPointFolder->getCombinedIdentifier()];
} else {
return $this->storageHashNumbers[$storageObject->getUid()];
}
} else {
return null;
}
}
示例15: findInStorageAndNotInUidList
/**
* Helper function for the Indexer to detect missing files
*
* @param \TYPO3\CMS\Core\Resource\ResourceStorage $storage
* @param array $uidList
* @return array
*/
public function findInStorageAndNotInUidList(\TYPO3\CMS\Core\Resource\ResourceStorage $storage, array $uidList)
{
$where = 'storage = ' . (int) $storage->getUid();
if (!empty($uidList)) {
$where .= ' AND uid NOT IN (' . implode(',', $this->getDatabaseConnection()->cleanIntArray($uidList)) . ')';
}
return $this->getDatabaseConnection()->exec_SELECTgetRows(implode(',', $this->fields), $this->table, $where);
}