文件uid在FAL文件上传字段挂钩中

时间:2014-08-19 13:25:13

标签: typo3 extbase typo3-6.2.x

我扩展了ExtendedFileUtilityProcessDataHookInterface并为FAL文件上传字段创建了一个钩子。

class tx_bibusdocuments_fileUploadHook implements TYPO3\CMS\Core\Utility\File\ExtendedFileUtilityProcessDataHookInterface {

public function processData_postProcessAction($action, array $cmdArr, array $result, \TYPO3\CMS\Core\Utility\File\ExtendedFileUtility $parentObject){}
}

当我打印“$ result”数组时,我得到了一个这样的数组;

    Array
    (
        [0] => Array
            (
                [0] => TYPO3\CMS\Core\Resource\File Object
                    (
                        [metaDataLoaded:protected] =>
                        [metaDataProperties:protected] => Array
                            (
                            )

                        [indexingInProgress:protected] =>
                        [updatedProperties:protected] => Array
                            (
                            )

                        [indexerService:protected] =>
                        [properties:protected] => Array
                            (
                                [size] => 198218
                                [modification_date] => 1408449118
                                [creation_date] => 1408449118
                                [mime_type] => application/pdf
                                [name] => HomeTest.pdf
                                [identifier] => /user_upload/test.pdf
                                [identifier_hash] => 2bc8d0c4ed9f8a87fb9913af5dcd3977e0102027
                                [storage] => 1
                                [folder_hash] => e32a309fabc28dd85f053b65c5bd0da99860eb02
                                [type] => 5
                                [sha1] => 8a46595222d30c9cb4bcc48a4901d3e0f05e25ad
                                [extension] => pdf
                                [missing] => 0
                                [uid] => 139856
                            )
                   )
       )
) 

如何从这个$ result数组中获取文件的uid和名称?

1 个答案:

答案 0 :(得分:1)

我们可以这样迭代结果数组;

public function processData_postProcessAction($action, array $cmdArr, array $result, \TYPO3\CMS\Core\Utility\File\ExtendedFileUtility $parentObject){
    $files = array_pop( $result );
    if ( !is_array( $files ) ) {
        return;
    }
    foreach ( $files as $file ) {
        $fileUid .= $file->getUid();  // Uid of the file
        $fileName .= $file->getName();  // Name of the file
    }
}