Commit 626f925f authored by Sascha Egerer's avatar Sascha Egerer Committed by Georg Ringer
Browse files

[FOLLOWUP][FEATURE] Introduce Data Processor for Files

* Reformatted Changelog Documentation
* Add array type to function arguments to force parameter type

Resolves: #67662
Releases: master
Change-Id: I896633527345489394a920e5b351b1e584defe08
Reviewed-on: http://review.typo3.org/41078


Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
parent ae6fbfc7
......@@ -14,41 +14,46 @@ over processed data automatically.
.. code-block:: typoscript
tt_content.image.20 = FLUIDTEMPLATE
tt_content.image.20.file = EXT:myextension/Resources/Private/Templates/ContentObjects/Image.html
tt_content.image.20.dataProcessing.10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
# the field name where relations are set
# + stdWrap
tt_content.image.20.dataProcessing.10.references.fieldName = image
# the table name where relations are put, defaults to the currently selected record from $cObj->getTable()
# + stdWrap
tt_content.image.20.dataProcessing.10.references.table = tt_content
# A list of sys_file UID records
# + stdWrap
tt_content.image.20.dataProcessing.10.files = 21,42
# A list of File Collection UID records
# + stdWrap
tt_content.image.20.dataProcessing.10.collections = 13,14
# A list of FAL Folder identifiers
# + stdWrap
tt_content.image.20.dataProcessing.10.folders = 1:introduction/images/,1:introduction/posters/
# Property of which the files should be sorted after they have been accumulated + stdWrap
# can be any property of sys_file, sys_file_metadata
tt_content.image.20.dataProcessing.10.sorting = description
# Can be "ascending", "descending" or "random", defaults to "ascending" if none given + stdWrap
tt_content.image.20.dataProcessing.10.sorting.direction = descending
# The target variable to be handed to the ContentObject again, can be used
# in Fluid e.g. to iterate over the objects. defaults to "files" when non given
# + stdWrap
tt_content.image.20.dataProcessing.10.as = myfiles
tt_content.image.20 {
file = EXT:myextension/Resources/Private/Templates/ContentObjects/Image.html
dataProcessing.10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
dataProcessing.10 {
# the field name where relations are set
# + stdWrap
references.fieldName = image
# the table name where relations are put, defaults to the currently selected record from $cObj->getTable()
# + stdWrap
references.table = tt_content
# A list of sys_file UID records
# + stdWrap
files = 21,42
# A list of File Collection UID records
# + stdWrap
collections = 13,14
# A list of FAL Folder identifiers
# + stdWrap
folders = 1:introduction/images/,1:introduction/posters/
# Property of which the files should be sorted after they have been accumulated
# can be any property of sys_file, sys_file_metadata
# + stdWrap
sorting = description
# Can be "ascending", "descending" or "random", defaults to "ascending" if none given
# + stdWrap
sorting.direction = descending
# The target variable to be handed to the ContentObject again, can be used
# in Fluid e.g. to iterate over the objects. defaults to "files" when not defined
# + stdWrap
as = myfiles
}
}
In the Fluid template then iterate over the files:
......
......@@ -66,7 +66,7 @@ class FileCollector implements \Countable {
*
* @param array $fileUids
*/
public function addFiles($fileUids = array()) {
public function addFiles(array $fileUids = array()) {
if (!empty($fileUids)) {
foreach ($fileUids as $fileUid) {
try {
......@@ -90,7 +90,7 @@ class FileCollector implements \Countable {
* @param array $referenceRecord the record which is referencing the files
* @return void
*/
public function addFilesFromRelation($relationTable, $relationField, $referenceRecord) {
public function addFilesFromRelation($relationTable, $relationField, array $referenceRecord) {
if (is_object($GLOBALS['TSFE']) && is_object($GLOBALS['TSFE']->sys_page)) {
$fileReferences = $GLOBALS['TSFE']->sys_page->getFileReferences($relationTable, $relationField, $referenceRecord);
} else {
......@@ -108,12 +108,10 @@ class FileCollector implements \Countable {
* @param array $fileReferenceUids
* @return void
*/
public function addFileReferences($fileReferenceUids = array()) {
if (!empty($fileReferenceUids)) {
foreach ($fileReferenceUids as $fileReferenceUid) {
$fileObject = $this->getFileRepository()->findFileReferenceByUid($fileReferenceUid);
$this->addFileObject($fileObject);
}
public function addFileReferences(array $fileReferenceUids = array()) {
foreach ($fileReferenceUids as $fileReferenceUid) {
$fileObject = $this->getFileRepository()->findFileReferenceByUid($fileReferenceUid);
$this->addFileObject($fileObject);
}
}
......@@ -123,11 +121,9 @@ class FileCollector implements \Countable {
* @param array $fileCollectionUids The file collections uids
* @return void
*/
public function addFilesFromFileCollections($fileCollectionUids = array()) {
if (!empty($fileCollectionUids)) {
foreach ($fileCollectionUids as $fileCollectionUid) {
$this->addFilesFromFileCollection($fileCollectionUid);
}
public function addFilesFromFileCollections(array $fileCollectionUids = array()) {
foreach ($fileCollectionUids as $fileCollectionUid) {
$this->addFilesFromFileCollection($fileCollectionUid);
}
}
......@@ -164,11 +160,9 @@ class FileCollector implements \Countable {
* @param array $folderIdentifiers The folder identifiers
* @return void
*/
public function addFilesFromFolders($folderIdentifiers = array()) {
if (!empty($folderIdentifiers)) {
foreach ($folderIdentifiers as $folderIdentifier) {
$this->addFilesFromFolder($folderIdentifier);
}
public function addFilesFromFolders(array $folderIdentifiers = array()) {
foreach ($folderIdentifiers as $folderIdentifier) {
$this->addFilesFromFolder($folderIdentifier);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment