本文整理汇总了PHP中TYPO3\CMS\Core\Resource\ResourceFactory::getFileReferenceObject方法的典型用法代码示例。如果您正苦于以下问题:PHP ResourceFactory::getFileReferenceObject方法的具体用法?PHP ResourceFactory::getFileReferenceObject怎么用?PHP ResourceFactory::getFileReferenceObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Resource\ResourceFactory
的用法示例。
在下文中一共展示了ResourceFactory::getFileReferenceObject方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getResource
/**
* @param mixed $identity
* @return mixed
*/
public function getResource($identity)
{
$fileReference = $this->resourceFactory->getFileReferenceObject(intval($identity));
$file = $fileReference->getOriginalFile();
$fileReferenceProperties = $fileReference->getProperties();
$fileProperties = ResourceUtility::getFileArray($file);
ArrayUtility::mergeRecursiveWithOverrule($fileProperties, $fileReferenceProperties, TRUE, FALSE, FALSE);
return $fileProperties;
}
示例2: getImagesByPages
/**
* Get alle images on the given pages
*
* @param array $pages
*
* @return array
*/
protected function getImagesByPages(array $pages)
{
$images = array();
if (!sizeof($pages)) {
return $images;
}
$enabledFields = $this->pageRepository->enableFields('sys_file_reference');
$enabledFields .= $this->pageRepository->enableFields('tt_content');
$enabledFields .= $this->pageRepository->enableFields('pages');
$rows = $this->getDatabaseConnection()->exec_SELECTgetRows('sys_file_reference.*', 'sys_file_reference, tt_content, pages', 'sys_file_reference.tablenames = \'tt_content\' AND sys_file_reference.fieldname =\'image\' AND sys_file_reference.uid_foreign = tt_content.uid AND tt_content.pid = pages.uid AND pages.uid IN (' . implode(',', $pages) . ') ' . $enabledFields);
foreach ($rows as $row) {
$images[] = $this->resourceFactory->getFileReferenceObject($row['uid'], $row);
}
return $images;
}
示例3: getResources
/**
* @param array $record
* @return array
*/
public function getResources($record)
{
$databaseConnection = $this->getDatabaseConnection();
if (isset($record['t3ver_oid']) && (int) $record['t3ver_oid'] !== 0) {
$sqlRecordUid = $record['t3ver_oid'];
} else {
$sqlRecordUid = $record[$this->idField];
}
$fileReferences = [];
if (empty($GLOBALS['TSFE']->sys_page) === false) {
$fileReferences = $this->getFileReferences($this->getTable(), $this->getField(), $sqlRecordUid);
} else {
if ($GLOBALS['BE_USER']->workspaceRec['uid']) {
$versionWhere = 'AND sys_file_reference.deleted=0 AND (sys_file_reference.t3ver_wsid=0 OR ' . 'sys_file_reference.t3ver_wsid=' . $GLOBALS['BE_USER']->workspaceRec['uid'] . ') AND sys_file_reference.pid<>-1';
} else {
$versionWhere = 'AND sys_file_reference.deleted=0 AND sys_file_reference.t3ver_state<=0 AND ' . 'sys_file_reference.pid<>-1 AND sys_file_reference.hidden=0';
}
$references = $databaseConnection->exec_SELECTgetRows('uid', 'sys_file_reference', 'tablenames=' . $databaseConnection->fullQuoteStr($this->getTable(), 'sys_file_reference') . ' AND uid_foreign=' . (int) $sqlRecordUid . ' AND fieldname=' . $databaseConnection->fullQuoteStr($this->getField(), 'sys_file_reference') . $versionWhere, '', 'sorting_foreign', '', 'uid');
if (empty($references) === false) {
$referenceUids = array_keys($references);
$fileReferences = [];
if (empty($referenceUids) === false) {
foreach ($referenceUids as $referenceUid) {
try {
// Just passing the reference uid, the factory is doing workspace
// overlays automatically depending on the current environment
$fileReferences[] = $this->resourceFactory->getFileReferenceObject($referenceUid);
} catch (ResourceDoesNotExistException $exception) {
// No handling, just omit the invalid reference uid
continue;
}
}
}
}
}
$resources = [];
foreach ($fileReferences as $file) {
// Exclude workspace deleted files references
if ($file->getProperty('t3ver_state') !== VersionState::DELETE_PLACEHOLDER) {
$resources[] = $this->getResource($file);
}
}
return $resources;
}
示例4: getResources
/**
* @param array $record
* @return array
*/
public function getResources($record)
{
/** @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $contentObj */
$contentObjectRenderer = $this->configurationManager->getContentObject();
/** @var \TYPO3\CMS\Core\Database\DatabaseConnection $databaseConnection */
$databaseConnection = $this->getDatabaseConntection();
if (isset($record['t3ver_oid']) && (int) $record['t3ver_oid'] !== 0) {
$sqlRecordUid = $record['t3ver_oid'];
} else {
$sqlRecordUid = $record[$this->idField];
}
if (FALSE === empty($GLOBALS['TSFE']->sys_page)) {
$images = $this->getFileReferences($this->getTable(), $this->getField(), $sqlRecordUid);
} else {
if ($GLOBALS['BE_USER']->workspaceRec['uid']) {
$versionWhere = 'AND sys_file_reference.deleted=0 AND (sys_file_reference.t3ver_wsid=0 OR sys_file_reference.t3ver_wsid=' . $GLOBALS['BE_USER']->workspaceRec['uid'] . ') AND sys_file_reference.pid<>-1';
} else {
$versionWhere = 'AND sys_file_reference.deleted=0 AND sys_file_reference.t3ver_state<=0 AND sys_file_reference.pid<>-1 AND sys_file_reference.hidden=0';
}
$references = $databaseConnection->exec_SELECTgetRows('uid', 'sys_file_reference', 'tablenames=' . $databaseConnection->fullQuoteStr($this->getTable(), 'sys_file_reference') . ' AND uid_foreign=' . (int) $sqlRecordUid . ' AND fieldname=' . $databaseConnection->fullQuoteStr($this->getField(), 'sys_file_reference') . $versionWhere, '', 'sorting_foreign', '', 'uid');
if (FALSE === empty($references)) {
$referenceUids = array_keys($references);
}
$images = array();
if (FALSE === empty($referenceUids)) {
foreach ($referenceUids as $referenceUid) {
try {
// Just passing the reference uid, the factory is doing workspace
// overlays automatically depending on the current environment
$images[] = $this->resourceFactory->getFileReferenceObject($referenceUid);
} catch (ResourceDoesNotExistException $exception) {
// No handling, just omit the invalid reference uid
continue;
}
}
}
}
$resources = array();
foreach ($images as $file) {
$resources[] = $this->getResource($file);
}
return $resources;
}
示例5: convertFrom
/**
* Actually convert from $source to $targetType, taking into account the fully
* built $convertedChildProperties and $configuration.
*
* @param string|integer $source
* @param string $targetType
* @param array $convertedChildProperties
* @param \TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface $configuration
* @throws \TYPO3\CMS\Extbase\Property\Exception
* @return \TYPO3\CMS\Extbase\Domain\Model\AbstractFileFolder
* @api
*/
public function convertFrom($source, $targetType, array $convertedChildProperties = array(), PropertyMappingConfigurationInterface $configuration = NULL)
{
if (!isset($source['error']) || $source['error'] === \UPLOAD_ERR_NO_FILE) {
if (isset($source['submittedFile']['resourcePointer'])) {
try {
$resourcePointer = $this->hashService->validateAndStripHmac($source['submittedFile']['resourcePointer']);
if (strpos($resourcePointer, 'file:') === 0) {
$fileUid = substr($resourcePointer, 5);
return $this->createFileReferenceFromFalFileObject($this->resourceFactory->getFileObject($fileUid));
} else {
return $this->createFileReferenceFromFalFileReferenceObject($this->resourceFactory->getFileReferenceObject($resourcePointer), $resourcePointer);
}
} catch (\InvalidArgumentException $e) {
// Nothing to do. No file is uploaded and resource pointer is invalid. Discard!
}
}
return NULL;
}
if ($source['error'] !== \UPLOAD_ERR_OK) {
switch ($source['error']) {
case \UPLOAD_ERR_INI_SIZE:
case \UPLOAD_ERR_FORM_SIZE:
case \UPLOAD_ERR_PARTIAL:
return new Error(Files::getUploadErrorMessage($source['error']), 1264440823);
default:
return new Error('An error occurred while uploading. Please try again or contact the administrator if the problem remains', 1340193849);
}
}
if (isset($this->convertedResources[$source['tmp_name']])) {
return $this->convertedResources[$source['tmp_name']];
}
try {
$resource = $this->importUploadedResource($source, $configuration);
} catch (\Exception $e) {
return new Error($e->getMessage(), $e->getCode());
}
$this->convertedResources[$source['tmp_name']] = $resource;
return $resource;
}
示例6: getInfoByReference
/**
* @param integer $id
* @return array
*/
public function getInfoByReference($id)
{
$fileReference = $this->resourceFactory->getFileReferenceObject($id);
$file = $fileReference->getOriginalFile();
return ResourceUtility::getFileArray($file);
}