Reputation: 185
I've extended ExtendedFileUtilityProcessDataHookInterface and created a hook for FAL file upload field.
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){}
}
When I print the "$result" array, I got an array like this;
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
)
)
)
)
How can I get uid and name of the file from this $result array?
Upvotes: 0
Views: 705
Reputation: 185
We can iterate the result array like this way;
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
}
}
Upvotes: 1