Skip to content

Commit

Permalink
[FEATURE] switch mask content elements rendering to FLUIDTEMPLATE
Browse files Browse the repository at this point in the history
  • Loading branch information
butu committed Sep 16, 2018
1 parent 198237f commit a8dfdcd
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 17 deletions.
9 changes: 3 additions & 6 deletions Classes/CodeGenerator/TyposcriptCodeGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,13 @@ classes {
}
}
';
// Load setup.ts Template
$template = file_get_contents(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('mask') . "Resources/Private/Mask/setup.ts",
true);
// Fill setup.ts:
if ($configuration["tt_content"]["elements"]) {
foreach ($configuration["tt_content"]["elements"] as $element) {
if (!$element["hidden"]) {
$temp = str_replace("###KEY###", $element["key"], $template);
$temp = str_replace("###PATH###", $settings['content'] . $element["key"] . '.html', $temp);
$setupContent .= $temp;
$setupContent .= "tt_content.mask_" . $element["key"] .
" =< lib.maskContentElement\ntt_content.mask_" . $element["key"] .
" {\ntemplateName = " . $element["key"] . "\n}\n\n";
}
}
}
Expand Down
43 changes: 43 additions & 0 deletions Classes/DataProcessing/MaskProcessor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace MASK\Mask\DataProcessing;

use MASK\Mask\Helper\InlineHelper;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;

class MaskProcessor extends \TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
{

/**
* InlineHelper
*
* @var \MASK\Mask\Helper\InlineHelper
* @Inject()
*/
protected $inlineHelper;

/**
* Process data of a record to add files and inline elements of mask fields
*
* @param ContentObjectRenderer $cObj The data of the content element or page
* @param array $contentObjectConfiguration The configuration of Content Object
* @param array $processorConfiguration The configuration of this processor
* @param array $processedData Key/value store of processed data (e.g. to be passed to a Fluid View)
* @return array the processed data as key/value store
*/
public function process(
ContentObjectRenderer $cObj,
array $contentObjectConfiguration,
array $processorConfiguration,
array $processedData
) {
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$this->inlineHelper = $objectManager->get(InlineHelper::class);

$this->inlineHelper->addFilesToData($processedData['data'], "tt_content");
$this->inlineHelper->addIrreToData($processedData['data']);
return $processedData;
}
}
9 changes: 9 additions & 0 deletions Configuration/TypoScript/setup.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ lib.tx_mask.content {
dontCheckPid = 1
}

# mask content elements are rendered with this snippet
lib.maskContentElement = FLUIDTEMPLATE
lib.maskContentElement {
dataProcessing {
100 = MASK\Mask\DataProcessing\MaskProcessor
}
}


# Temporary page cObject:
temp.mask.page = PAGE
temp.mask.page {
Expand Down
11 changes: 0 additions & 11 deletions Resources/Private/Mask/setup.ts

This file was deleted.

0 comments on commit a8dfdcd

Please sign in to comment.