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


PHP Folder::addFile方法代码示例

本文整理汇总了PHP中TYPO3\CMS\Core\Resource\Folder::addFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::addFile方法的具体用法?PHP Folder::addFile怎么用?PHP Folder::addFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TYPO3\CMS\Core\Resource\Folder的用法示例。


在下文中一共展示了Folder::addFile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setRelations

 /**
  * At the end of the import process all file and DB relations should be set properly (that is relations
  * to imported records are all re-created so imported records are correctly related again)
  * Relations in flexform fields are processed in setFlexFormRelations() after this function
  *
  * @return void
  * @see setFlexFormRelations()
  */
 public function setRelations()
 {
     $updateData = array();
     // import_newId contains a register of all records that was in the import memorys "records" key
     foreach ($this->import_newId as $nId => $dat) {
         $table = $dat['table'];
         $uid = $dat['uid'];
         // original UID - NOT the new one!
         // If the record has been written and received a new id, then proceed:
         if (is_array($this->import_mapId[$table]) && isset($this->import_mapId[$table][$uid])) {
             $thisNewUid = BackendUtility::wsMapId($table, $this->import_mapId[$table][$uid]);
             if (is_array($this->dat['records'][$table . ':' . $uid]['rels'])) {
                 $thisNewPageUid = 0;
                 if ($this->legacyImport) {
                     if ($table != 'pages') {
                         $oldPid = $this->dat['records'][$table . ':' . $uid]['data']['pid'];
                         $thisNewPageUid = BackendUtility::wsMapId($table, $this->import_mapId['pages'][$oldPid]);
                     } else {
                         $thisNewPageUid = $thisNewUid;
                     }
                 }
                 // Traverse relation fields of each record
                 foreach ($this->dat['records'][$table . ':' . $uid]['rels'] as $field => $config) {
                     // uid_local of sys_file_reference needs no update because the correct reference uid was already written
                     // @see ImportExport::fixUidLocalInSysFileReferenceRecords()
                     if ($table === 'sys_file_reference' && $field === 'uid_local') {
                         continue;
                     }
                     switch ((string) $config['type']) {
                         case 'db':
                             if (is_array($config['itemArray']) && !empty($config['itemArray'])) {
                                 $itemConfig = $GLOBALS['TCA'][$table]['columns'][$field]['config'];
                                 $valArray = $this->setRelations_db($config['itemArray'], $itemConfig);
                                 $updateData[$table][$thisNewUid][$field] = implode(',', $valArray);
                             }
                             break;
                         case 'file':
                             if (is_array($config['newValueFiles']) && !empty($config['newValueFiles'])) {
                                 $valArr = array();
                                 foreach ($config['newValueFiles'] as $fI) {
                                     $valArr[] = $this->import_addFileNameToBeCopied($fI);
                                 }
                                 if ($this->legacyImport && $this->legacyImportFolder === null && isset($this->legacyImportMigrationTables[$table][$field])) {
                                     // Do nothing - the legacy import folder is missing
                                 } elseif ($this->legacyImport && $this->legacyImportFolder !== null && isset($this->legacyImportMigrationTables[$table][$field])) {
                                     $refIds = array();
                                     foreach ($valArr as $tempFile) {
                                         $fileName = $this->alternativeFileName[$tempFile];
                                         $fileObject = null;
                                         try {
                                             // check, if there is alreay the same file in the folder
                                             if ($this->legacyImportFolder->hasFile($fileName)) {
                                                 $fileStorage = $this->legacyImportFolder->getStorage();
                                                 $file = $fileStorage->getFile($this->legacyImportFolder->getIdentifier() . $fileName);
                                                 if ($file->getSha1() === sha1_file($tempFile)) {
                                                     $fileObject = $file;
                                                 }
                                             }
                                         } catch (Exception $e) {
                                         }
                                         if ($fileObject === null) {
                                             try {
                                                 $fileObject = $this->legacyImportFolder->addFile($tempFile, $fileName, DuplicationBehavior::RENAME);
                                             } catch (Exception $e) {
                                                 $this->error('Error: no file could be added to the storage for file name' . $this->alternativeFileName[$tempFile]);
                                             }
                                         }
                                         if ($fileObject !== null) {
                                             $refId = StringUtility::getUniqueId('NEW');
                                             $refIds[] = $refId;
                                             $updateData['sys_file_reference'][$refId] = array('uid_local' => $fileObject->getUid(), 'uid_foreign' => $thisNewUid, 'tablenames' => $table, 'fieldname' => $field, 'pid' => $thisNewPageUid, 'table_local' => 'sys_file');
                                         }
                                     }
                                     $updateData[$table][$thisNewUid][$field] = implode(',', $refIds);
                                     if (!empty($this->legacyImportMigrationTables[$table][$field])) {
                                         $this->legacyImportMigrationRecords[$table][$thisNewUid][$field] = $refIds;
                                     }
                                 } else {
                                     $updateData[$table][$thisNewUid][$field] = implode(',', $valArr);
                                 }
                             }
                             break;
                     }
                 }
             } else {
                 $this->error('Error: no record was found in data array!');
             }
         } else {
             $this->error('Error: this records is NOT created it seems! (' . $table . ':' . $uid . ')');
         }
     }
     if (!empty($updateData)) {
//.........这里部分代码省略.........
开发者ID:franzholz,项目名称:TYPO3.CMS,代码行数:101,代码来源:ImportExport.php

示例2: createNewFile

 /**
  * Create new OnlineMedia item container file
  *
  * @param Folder $targetFolder
  * @param string $fileName
  * @param string $onlineMediaId
  * @return File
  */
 protected function createNewFile(Folder $targetFolder, $fileName, $onlineMediaId)
 {
     $tempFilePath = GeneralUtility::tempnam('online_media');
     file_put_contents($tempFilePath, $onlineMediaId);
     return $targetFolder->addFile($tempFilePath, $fileName, 'changeName');
 }
开发者ID:rickymathew,项目名称:TYPO3.CMS,代码行数:14,代码来源:AbstractOnlineMediaHelper.php

示例3: createNewFile

 /**
  * Create new OnlineMedia item container file.
  * This is created inside typo3temp/ and then moved from FAL to the proper storage.
  *
  * @param Folder $targetFolder
  * @param string $fileName
  * @param string $onlineMediaId
  * @return File
  */
 protected function createNewFile(Folder $targetFolder, $fileName, $onlineMediaId)
 {
     $temporaryFile = PATH_site . 'typo3temp/assets/transient/' . GeneralUtility::tempnam('online_media');
     GeneralUtility::writeFileToTypo3tempDir($temporaryFile, $onlineMediaId);
     return $targetFolder->addFile($temporaryFile, $fileName, 'changeName');
 }
开发者ID:vip3out,项目名称:TYPO3.CMS,代码行数:15,代码来源:AbstractOnlineMediaHelper.php

示例4: createNewFile

 /**
  * Create new OnlineMedia item container file.
  * This is created inside typo3temp/ and then moved from FAL to the proper storage.
  *
  * @param Folder $targetFolder
  * @param string $fileName
  * @param string $onlineMediaId
  * @return File
  */
 protected function createNewFile(Folder $targetFolder, $fileName, $onlineMediaId)
 {
     $temporaryFile = GeneralUtility::tempnam('online_media');
     GeneralUtility::writeFileToTypo3tempDir($temporaryFile, $onlineMediaId);
     $file = $targetFolder->addFile($temporaryFile, $fileName, DuplicationBehavior::RENAME);
     GeneralUtility::unlink_tempfile($temporaryFile);
     return $file;
 }
开发者ID:TYPO3Incubator,项目名称:TYPO3.CMS,代码行数:17,代码来源:AbstractOnlineMediaHelper.php


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