本文整理汇总了PHP中TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::getCurrentTable方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentObjectRenderer::getCurrentTable方法的具体用法?PHP ContentObjectRenderer::getCurrentTable怎么用?PHP ContentObjectRenderer::getCurrentTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
的用法示例。
在下文中一共展示了ContentObjectRenderer::getCurrentTable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
/**
* Process data of a record to resolve File objects to the view
*
* @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)
{
if (isset($processorConfiguration['if.']) && !$cObj->checkIf($processorConfiguration['if.'])) {
return $processedData;
}
// gather data
/** @var FileCollector $fileCollector */
$fileCollector = GeneralUtility::makeInstance(FileCollector::class);
$settings = $contentObjectConfiguration['settings.']['display_mode.'];
// references / relations
if (!empty($processorConfiguration['references.'])) {
$referenceConfiguration = $processorConfiguration['references.'];
$relationField = $cObj->stdWrapValue('fieldName', $referenceConfiguration);
// If no reference fieldName is set, there's nothing to do
if (!empty($relationField)) {
// Fetch the references of the default element
$relationTable = $cObj->stdWrapValue('table', $referenceConfiguration, $cObj->getCurrentTable());
if (!empty($relationTable)) {
$fileCollector->addFilesFromRelation($relationTable, $relationField, $cObj->data);
}
}
}
// Get files from database-record
$files = $fileCollector->getFiles();
if (count($files) > 0) {
// Use ImageService for further processing
$imageService = self::getImageService();
foreach ($files as $file) {
$displayMode = $file->getReferenceProperty('display_mode');
$image = $imageService->getImage(null, $file, true);
$processingInstructions = ['crop' => $image->getProperty('crop')];
$maxWidth = intval($contentObjectConfiguration['settings.']['display_mode_maxWidth.'][$displayMode]);
if ($maxWidth > 0) {
$processingInstructions['maxWidth'] = $maxWidth;
}
$processedImage = $imageService->applyProcessingInstructions($image, $processingInstructions);
$styleAttribute = 'background-image:url(\'' . $imageService->getImageUri($processedImage) . '\');';
switch ($displayMode) {
case '1':
$targetVariableName = 'layoutMedia';
break;
default:
$targetVariableName = 'backgroundMedia';
break;
}
$processedData[$targetVariableName]['fileReference'] = $file;
$processedData[$targetVariableName]['class'] = $settings[$displayMode];
$processedData[$targetVariableName]['style'] = $styleAttribute;
}
}
//\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($files, '$files');
return $processedData;
}
示例2: process
/**
* Process data of a record to resolve File objects to the view
*
* @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)
{
if (isset($processorConfiguration['if.']) && !$cObj->checkIf($processorConfiguration['if.'])) {
return $processedData;
}
// gather data
/** @var FileCollector $fileCollector */
$fileCollector = GeneralUtility::makeInstance(FileCollector::class);
// references / relations
if (!empty($processorConfiguration['references.'])) {
$referenceConfiguration = $processorConfiguration['references.'];
$relationField = $cObj->stdWrapValue('fieldName', $referenceConfiguration);
// If no reference fieldName is set, there's nothing to do
if (!empty($relationField)) {
// Fetch the references of the default element
$relationTable = $cObj->stdWrapValue('table', $referenceConfiguration, $cObj->getCurrentTable());
if (!empty($relationTable)) {
$fileCollector->addFilesFromRelation($relationTable, $relationField, $cObj->data);
}
}
}
// files
$files = $cObj->stdWrapValue('files', $processorConfiguration);
if ($files) {
$files = GeneralUtility::intExplode(',', $files, TRUE);
$fileCollector->addFiles($files);
}
// collections
$collections = $cObj->stdWrapValue('collections', $processorConfiguration);
if (!empty($collections)) {
$collections = GeneralUtility::trimExplode(',', $collections, TRUE);
$fileCollector->addFilesFromFileCollections($collections);
}
// folders
$folders = $cObj->stdWrapValue('folders', $processorConfiguration);
if (!empty($folders)) {
$folders = GeneralUtility::trimExplode(',', $folders, TRUE);
$fileCollector->addFilesFromFolders($folders);
}
// make sure to sort the files
$sortingProperty = $cObj->stdWrapValue('sorting', $processorConfiguration);
if ($sortingProperty) {
$sortingDirection = $cObj->stdWrapValue('direction', isset($processorConfiguration['sorting.']) ? $processorConfiguration['sorting.'] : array(), 'ascending');
$fileCollector->sort($sortingProperty, $sortingDirection);
}
// set the files into a variable, default "files"
$targetVariableName = $cObj->stdWrapValue('as', $processorConfiguration, 'files');
$processedData[$targetVariableName] = $fileCollector->getFiles();
return $processedData;
}
示例3: postProcessContentObjectInitialization
/**
* Hook to extend the Data Array of the Object with the FlexForm fields
*
* @param \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $pObject
* @return bool
*/
public function postProcessContentObjectInitialization(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer &$pObject)
{
if (isset($pObject->data['tx_contentdesigner_flexform'])) {
$objData = $pObject->data['tx_contentdesigner_flexform'];
} elseif (isset($GLOBALS['TSFE']->page['tx_contentdesigner_flexform'])) {
$objData = $GLOBALS['TSFE']->page['tx_contentdesigner_flexform'];
} else {
return false;
}
if (empty($objData)) {
return false;
}
$ffh = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Service\\FlexFormService');
$flexArray = $ffh->convertFlexFormContentToArray($objData);
if (is_array($flexArray['settings']['flexform'])) {
if ($pObject->getCurrentTable() == 'pages') {
$this->mergeData($pObject, $flexArray['settings']['flexform']);
}
if ($pObject->getCurrentTable() == 'tt_content') {
$this->mergeData($pObject, $flexArray['settings']['flexform']);
}
unset($flexArray['settings']['flexform']);
}
if (is_array($flexArray['settings'])) {
if ($pObject->getCurrentTable() == 'pages') {
$this->mergeData($pObject, $flexArray['settings']);
}
if ($pObject->getCurrentTable() == 'tt_content') {
$this->mergeData($pObject, $flexArray['settings']);
}
unset($flexArray['settings']);
}
if (sizeof($flexArray) > 0) {
if ($pObject->getCurrentTable() == 'pages') {
$this->mergeData($pObject, $flexArray);
}
if ($pObject->getCurrentTable() == 'tt_content') {
$this->mergeData($pObject, $flexArray);
}
unset($flexArray);
}
}