Commit be434f2f authored by Claus Due's avatar Claus Due Committed by Benni Mack
Browse files

[TASK] Refactor fluid page module components

Refactoring with the goal of:

* Restoring entity-like nature of BackendLayout
* Decreasing coupling between components of the page
  module processing and rendering.

Implements a PageLayoutContext to hold all context-related
objects and methods and passes the context to objects
instead of passing the BackendLayout. Reduces number of
methods on DrawingConfiguration so the configuration object
only holds output- and behavior-related options and does not
hold things like permission checks.

Releases: master
Resolves: #90882
Change-Id: I09f1d97a53a76ea96d6cbc18bb5549127b5a1a71
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/64002

Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Susanne Moog's avatarSusanne Moog <look@susi.dev>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Susanne Moog's avatarSusanne Moog <look@susi.dev>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent cb9863f5
......@@ -25,6 +25,7 @@ use TYPO3\CMS\Backend\Template\Components\ButtonBar;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\View\BackendLayoutView;
use TYPO3\CMS\Backend\View\PageLayoutContext;
use TYPO3\CMS\Backend\View\PageLayoutView;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Configuration\Features;
......@@ -160,9 +161,9 @@ class PageLayoutController
protected $uriBuilder;
/**
* @var BackendLayoutView
* @var PageLayoutContext
*/
protected $backendLayouts;
protected $context;
/**
* Injects the request object for the current request or subrequest
......@@ -179,13 +180,18 @@ class PageLayoutController
$this->iconFactory = $this->moduleTemplate->getIconFactory();
$this->uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$this->buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
$this->backendLayouts = GeneralUtility::makeInstance(BackendLayoutView::class);
$this->getLanguageService()->includeLLFile('EXT:backend/Resources/Private/Language/locallang_layout.xlf');
// Setting module configuration / page select clause
$this->id = (int)($request->getParsedBody()['id'] ?? $request->getQueryParams()['id'] ?? 0);
// Load page info array
$this->pageinfo = BackendUtility::readPageAccess($this->id, $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW));
$this->context = GeneralUtility::makeInstance(
PageLayoutContext::class,
$this->pageinfo,
GeneralUtility::makeInstance(BackendLayoutView::class)->getBackendLayoutForPage($this->id)
);
/** @var SiteInterface $currentSite */
$currentSite = $request->getAttribute('site');
$this->availableLanguages = $currentSite->getAvailableLanguages($this->getBackendUser(), false, $this->id);
......@@ -547,8 +553,9 @@ class PageLayoutController
}
');
$backendLayout = $this->context->getBackendLayout();
// Find backend layout / columns
$backendLayout = $this->backendLayouts->getBackendLayoutForPage($this->id);
if (!empty($backendLayout->getColumnPositionNumbers())) {
$this->colPosList = implode(',', $backendLayout->getColumnPositionNumbers());
}
......@@ -619,26 +626,26 @@ class PageLayoutController
$this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/LayoutModule/Paste');
$this->pageRenderer->addInlineLanguageLabelFile('EXT:backend/Resources/Private/Language/locallang_layout.xlf');
$backendLayout = $this->backendLayouts->getBackendLayoutForPage((int)$this->id);
$backendLayout = $this->context->getBackendLayout();
$configuration = $backendLayout->getDrawingConfiguration();
$configuration->setPageId($this->id);
$configuration = $this->context->getDrawingConfiguration();
$configuration->setDefaultLanguageBinding(!empty($this->modTSconfig['properties']['defLangBinding']));
$configuration->setActiveColumns(GeneralUtility::trimExplode(',', $this->activeColPosList));
$configuration->setShowHidden((bool)$this->MOD_SETTINGS['tt_content_showHidden']);
$configuration->setLanguageColumns($this->MOD_MENU['language']);
$configuration->setLanguageColumnsPointer((int)$this->current_sys_language);
$configuration->setShowNewContentWizard(empty($this->modTSconfig['properties']['disableNewContentElementWizard']));
$configuration->setSelectedLanguageId((int)$this->MOD_SETTINGS['language']);
if ($this->MOD_SETTINGS['function'] == 2) {
$configuration->setLanguageMode(true);
}
$configuration->setShowNewContentWizard(empty($this->modTSconfig['properties']['disableNewContentElementWizard']));
$numberOfHiddenElements = $this->getNumberOfHiddenElements($configuration->getLanguageColumns());
if (GeneralUtility::makeInstance(Features::class)->isFeatureEnabled('fluidBasedPageModule')) {
$pageLayoutDrawer = $backendLayout->getBackendLayoutRenderer();
$pageLayoutDrawer = $this->context->getBackendLayoutRenderer();
$pageActionsCallback = null;
if ($configuration->isPageEditable()) {
if ($this->context->isPageEditable()) {
$languageOverlayId = 0;
$pageLocalizationRecord = BackendUtility::getRecordLocalization('pages', $this->id, (int)$this->current_sys_language);
if (is_array($pageLocalizationRecord)) {
......@@ -655,7 +662,7 @@ class PageLayoutController
$this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/PageActions', $pageActionsCallback);
$tableOutput = $pageLayoutDrawer->drawContent();
} else {
$dbList = PageLayoutView::createFromDrawingConfiguration($configuration);
$dbList = PageLayoutView::createFromPageLayoutContext($this->context);
// Setting up the tt_content columns to show
$colList = array_keys($backendLayout->getUsedColumns());
if ($this->colPosList !== '') {
......
......@@ -54,7 +54,7 @@ class StandardContentPreviewRenderer implements PreviewRendererInterface, Logger
public function renderPageModulePreviewHeader(GridColumnItem $item): string
{
$record = $item->getRecord();
$itemLabels = $item->getBackendLayout()->getDrawingConfiguration()->getItemLabels();
$itemLabels = $item->getContext()->getItemLabels();
$outHeader = '';
......@@ -81,14 +81,14 @@ class StandardContentPreviewRenderer implements PreviewRendererInterface, Logger
$out = '';
$record = $item->getRecord();
$contentTypeLabels = $item->getBackendLayout()->getDrawingConfiguration()->getContentTypeLabels();
$contentTypeLabels = $item->getContext()->getContentTypeLabels();
$languageService = $this->getLanguageService();
$drawItem = true;
$hookPreviewContent = '';
// Hook: Render an own preview of a record
if (!empty($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'])) {
$pageLayoutView = PageLayoutView::createFromDrawingConfiguration($item->getBackendLayout()->getDrawingConfiguration());
$pageLayoutView = PageLayoutView::createFromPageLayoutContext($item->getContext());
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'] ?? [] as $className) {
$hookObject = GeneralUtility::makeInstance($className);
if (!$hookObject instanceof PageLayoutViewDrawItemHookInterface) {
......@@ -169,7 +169,7 @@ class StandardContentPreviewRenderer implements PreviewRendererInterface, Logger
case 'list':
$hookOut = '';
if (!empty($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'])) {
$pageLayoutView = PageLayoutView::createFromDrawingConfiguration($item->getBackendLayout()->getDrawingConfiguration());
$pageLayoutView = PageLayoutView::createFromPageLayoutContext($item->getBackendLayout());
$_params = ['pObj' => &$pageLayoutView, 'row' => $record];
foreach (
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$record['list_type']] ??
......@@ -240,7 +240,7 @@ class StandardContentPreviewRenderer implements PreviewRendererInterface, Logger
// Call drawFooter hooks
if (!empty($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawFooter'])) {
$pageLayoutView = PageLayoutView::createFromDrawingConfiguration($item->getBackendLayout()->getDrawingConfiguration());
$pageLayoutView = PageLayoutView::createFromPageLayoutContext($item->getBackendLayout());
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawFooter'] ?? [] as $className) {
$hookObject = GeneralUtility::makeInstance($className);
if (!$hookObject instanceof PageLayoutViewDrawFooterHookInterface) {
......@@ -273,7 +273,7 @@ class StandardContentPreviewRenderer implements PreviewRendererInterface, Logger
protected function getProcessedValue(GridColumnItem $item, string $fieldList, array &$info): void
{
$itemLabels = $item->getBackendLayout()->getDrawingConfiguration()->getItemLabels();
$itemLabels = $item->getContext()->getItemLabels();
$record = $item->getRecord();
$fieldArr = explode(',', $fieldList);
foreach ($fieldArr as $field) {
......
......@@ -15,14 +15,7 @@
namespace TYPO3\CMS\Backend\View\BackendLayout;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\View\BackendLayout\Grid\Grid;
use TYPO3\CMS\Backend\View\BackendLayout\Grid\GridColumn;
use TYPO3\CMS\Backend\View\BackendLayout\Grid\GridRow;
use TYPO3\CMS\Backend\View\BackendLayout\Grid\LanguageColumn;
use TYPO3\CMS\Backend\View\BackendLayoutView;
use TYPO3\CMS\Backend\View\Drawing\BackendLayoutRenderer;
use TYPO3\CMS\Backend\View\Drawing\DrawingConfiguration;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
......@@ -67,26 +60,6 @@ class BackendLayout
*/
protected $data;
/**
* @var DrawingConfiguration
*/
protected $drawingConfiguration;
/**
* @var ContentFetcher
*/
protected $contentFetcher;
/**
* @var LanguageColumn[]
*/
protected $languageColumns = [];
/**
* @var RecordRememberer
*/
protected $recordRememberer;
/**
* @param string $identifier
* @param string $title
......@@ -110,9 +83,6 @@ class BackendLayout
*/
public function __construct($identifier, $title, $configuration)
{
$this->drawingConfiguration = GeneralUtility::makeInstance(DrawingConfiguration::class);
$this->contentFetcher = GeneralUtility::makeInstance(ContentFetcher::class, $this);
$this->recordRememberer = GeneralUtility::makeInstance(RecordRememberer::class);
$this->setIdentifier($identifier);
$this->setTitle($title);
if (is_array($configuration)) {
......@@ -250,90 +220,8 @@ class BackendLayout
return $this->structure;
}
/**
* @return LanguageColumn[]
*/
public function getLanguageColumns(): iterable
{
if (empty($this->languageColumns)) {
$availableLanguageColumns = $this->getDrawingConfiguration()->getLanguageColumns();
foreach ($this->getDrawingConfiguration()->getSiteLanguages() as $siteLanguage) {
if (!isset($availableLanguageColumns[$siteLanguage->getLanguageId()])) {
continue;
}
$backendLayout = clone $this;
$backendLayout->getDrawingConfiguration()->setLanguageColumnsPointer($siteLanguage->getLanguageId());
$this->languageColumns[] = GeneralUtility::makeInstance(LanguageColumn::class, $backendLayout, $siteLanguage);
}
}
return $this->languageColumns;
}
public function getGrid(): Grid
{
$grid = GeneralUtility::makeInstance(Grid::class, $this);
foreach ($this->structure['__config']['backend_layout.']['rows.'] ?? [] as $row) {
$rowObject = GeneralUtility::makeInstance(GridRow::class, $this);
foreach ($row['columns.'] as $column) {
$columnObject = GeneralUtility::makeInstance(GridColumn::class, $this, $column);
$rowObject->addColumn($columnObject);
}
$grid->addRow($rowObject);
}
$pageId = $this->drawingConfiguration->getPageId();
$allowInconsistentLanguageHandling = (bool)(BackendUtility::getPagesTSconfig($pageId)['mod.']['web_layout.']['allowInconsistentLanguageHandling'] ?? false);
if (!$allowInconsistentLanguageHandling && $this->getLanguageModeIdentifier() === 'connected') {
$grid->setAllowNewContent(false);
}
return $grid;
}
public function getColumnPositionNumbers(): array
{
return $this->structure['__colPosList'];
}
public function getContentFetcher(): ContentFetcher
{
return $this->contentFetcher;
}
public function setContentFetcher(ContentFetcher $contentFetcher): void
{
$this->contentFetcher = $contentFetcher;
}
public function getDrawingConfiguration(): DrawingConfiguration
{
return $this->drawingConfiguration;
}
public function setDrawingConfiguration(DrawingConfiguration $drawingConfiguration): void
{
$this->drawingConfiguration = $drawingConfiguration;
}
public function getBackendLayoutRenderer(): BackendLayoutRenderer
{
return GeneralUtility::makeInstance(BackendLayoutRenderer::class, $this);
}
public function getRecordRememberer(): RecordRememberer
{
return $this->recordRememberer;
}
public function getLanguageModeIdentifier(): string
{
$contentRecordsPerColumn = $this->contentFetcher->getContentRecordsPerColumn(null, $this->drawingConfiguration->getLanguageColumnsPointer());
$contentRecords = empty($contentRecordsPerColumn) ? [] : array_merge(...$contentRecordsPerColumn);
$translationData = $this->contentFetcher->getTranslationData($contentRecords, $this->drawingConfiguration->getLanguageColumnsPointer());
return $translationData['mode'] ?? '';
}
public function __clone()
{
$this->drawingConfiguration = clone $this->drawingConfiguration;
$this->contentFetcher->setBackendLayout($this);
}
}
......@@ -19,7 +19,10 @@ namespace TYPO3\CMS\Backend\View\BackendLayout;
use Doctrine\DBAL\Driver\Statement;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\View\PageLayoutContext;
use TYPO3\CMS\Backend\View\PageLayoutView;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Cache\Frontend\VariableFrontend;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
......@@ -41,30 +44,19 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
class ContentFetcher
{
/**
* @var BackendLayout
* @var PageLayoutContext
*/
protected $backendLayout;
protected $context;
/**
* @var array
*/
protected $fetchedContentRecords = [];
/**
* Stores whether a certain language has translations in it
*
* @var array
*/
protected $languageHasTranslationsCache = [];
public function __construct(BackendLayout $backendLayout)
public function __construct(PageLayoutContext $pageLayoutContext)
{
$this->backendLayout = $backendLayout;
}
public function setBackendLayout(BackendLayout $backendLayout): void
{
$this->backendLayout = $backendLayout;
$this->context = $pageLayoutContext;
$this->fetchedContentRecords = $this->getRuntimeCache()->get('ContentFetcher_fetchedContentRecords') ?: [];
}
/**
......@@ -77,18 +69,30 @@ class ContentFetcher
*/
public function getContentRecordsPerColumn(?int $columnNumber = null, ?int $languageId = null): iterable
{
$languageId = $languageId ?? $this->context->getSiteLanguage()->getLanguageId();
if (empty($this->fetchedContentRecords)) {
$isLanguageMode = $this->context->getDrawingConfiguration()->getLanguageMode();
$queryBuilder = $this->getQueryBuilder();
$records = $this->getResult($queryBuilder->execute());
foreach ($records as $record) {
$recordLanguage = (int)$record['sys_language_uid'];
$recordColumnNumber = (int)$record['colPos'];
if ($recordLanguage === -1) {
// Record is set to "all languages", place it according to view mode.
if ($isLanguageMode) {
// Force the record to only be shown in default language in "Languages" view mode.
$recordLanguage = 0;
} else {
// Force the record to be shown in the currently active language in "Columns" view mode.
$recordLanguage = $languageId;
}
}
$this->fetchedContentRecords[$recordLanguage][$recordColumnNumber][] = $record;
}
$this->getRuntimeCache()->set('ContentFetcher_fetchedContentRecords', $this->fetchedContentRecords);
}
$languageId = $languageId ?? $this->backendLayout->getDrawingConfiguration()->getLanguageColumnsPointer();
$contentByLanguage = &$this->fetchedContentRecords[$languageId];
if ($columnNumber === null) {
......@@ -98,9 +102,8 @@ class ContentFetcher
return $contentByLanguage[$columnNumber] ?? [];
}
public function getFlatContentRecords(): iterable
public function getFlatContentRecords(int $languageId): iterable
{
$languageId = $this->backendLayout->getDrawingConfiguration()->getLanguageColumnsPointer();
$contentRecords = $this->getContentRecordsPerColumn(null, $languageId);
return empty($contentRecords) ? [] : array_merge(...$contentRecords);
}
......@@ -114,11 +117,11 @@ class ContentFetcher
{
$unrendered = [];
$hookArray = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['record_is_used'] ?? [];
$pageLayoutView = PageLayoutView::createFromDrawingConfiguration($this->backendLayout->getDrawingConfiguration());
$pageLayoutView = PageLayoutView::createFromPageLayoutContext($this->context);
$knownColumnPositionNumbers = $this->backendLayout->getColumnPositionNumbers();
$rememberer = $this->backendLayout->getRecordRememberer();
foreach ($this->fetchedContentRecords[$this->backendLayout->getDrawingConfiguration()->getLanguageColumnsPointer()] ?? [] as $contentRecordsInColumn) {
$knownColumnPositionNumbers = $this->context->getBackendLayout()->getColumnPositionNumbers();
$rememberer = GeneralUtility::makeInstance(RecordRememberer::class);
foreach ($this->getContentRecordsPerColumn(null, 0) as $contentRecordsInColumn) {
foreach ($contentRecordsInColumn as $contentRecord) {
$used = $rememberer->isRemembered((int)$contentRecord['uid']);
// A hook mentioned that this record is used somewhere, so this is in fact "rendered" already
......@@ -136,47 +139,45 @@ class ContentFetcher
public function getTranslationData(iterable $contentElements, int $language): array
{
$configuration = $this->backendLayout->getDrawingConfiguration();
if ($language === 0) {
return [];
}
if (!isset($this->languageHasTranslationsCache[$language])) {
if ($language) {
$contentRecordsInDefaultLanguage = $this->getContentRecordsPerColumn(null, 0);
if (!empty($contentRecordsInDefaultLanguage)) {
$contentRecordsInDefaultLanguage = array_merge(...$contentRecordsInDefaultLanguage);
}
} else {
$contentRecordsInDefaultLanguage = $contentElements;
$languageTranslationInfo = $this->getRuntimeCache()->get('ContentFetcher_TranslationInfo_' . $language) ?: [];
if (empty($languageTranslationInfo)) {
$contentRecordsInDefaultLanguage = $this->getContentRecordsPerColumn(null, 0);
if (!empty($contentRecordsInDefaultLanguage)) {
$contentRecordsInDefaultLanguage = array_merge(...$contentRecordsInDefaultLanguage);
}
$untranslatedRecordUids = array_flip(array_column($contentRecordsInDefaultLanguage, 'uid'));
foreach ($contentElements as $contentElement) {
if ((int)$contentElement['sys_language_uid'] === -1) {
continue;
}
if ((int)$contentElement['l18n_parent'] === 0) {
$this->languageHasTranslationsCache[$language]['hasStandAloneContent'] = true;
$this->languageHasTranslationsCache[$language]['mode'] = 'free';
$languageTranslationInfo['hasStandAloneContent'] = true;
$languageTranslationInfo['mode'] = 'free';
}
if ((int)$contentElement['l18n_parent'] > 0) {
$this->languageHasTranslationsCache[$language]['hasTranslations'] = true;
$this->languageHasTranslationsCache[$language]['mode'] = 'connected';
$languageTranslationInfo['hasTranslations'] = true;
$languageTranslationInfo['mode'] = 'connected';
}
if ((int)$contentElement['l10n_source'] > 0) {
unset($untranslatedRecordUids[(int)$contentElement['l10n_source']]);
}
}
if (!isset($this->languageHasTranslationsCache[$language])) {
$this->languageHasTranslationsCache[$language]['hasTranslations'] = false;
if (!isset($languageTranslationInfo['hasTranslations'])) {
$languageTranslationInfo['hasTranslations'] = false;
}
$this->languageHasTranslationsCache[$language]['untranslatedRecordUids'] = array_keys($untranslatedRecordUids);
$languageTranslationInfo['untranslatedRecordUids'] = array_keys($untranslatedRecordUids);
// Check for inconsistent translations, force "mixed" mode and dispatch a FlashMessage to user if such a case is encountered.
if (isset($this->languageHasTranslationsCache[$language]['hasStandAloneContent'])
&& $this->languageHasTranslationsCache[$language]['hasTranslations']
if (isset($languageTranslationInfo['hasStandAloneContent'])
&& $languageTranslationInfo['hasTranslations']
) {
$this->languageHasTranslationsCache[$language]['mode'] = 'mixed';
$siteLanguage = $configuration->getSiteLanguage($language);
$languageTranslationInfo['mode'] = 'mixed';
$siteLanguage = $this->context->getSiteLanguage();
$message = GeneralUtility::makeInstance(
FlashMessage::class,
sprintf($this->getLanguageService()->getLL('staleTranslationWarning'), $siteLanguage->getTitle()),
......@@ -187,8 +188,10 @@ class ContentFetcher
$queue = $service->getMessageQueueByIdentifier();
$queue->addMessage($message);
}
$this->getRuntimeCache()->set('ContentFetcher_TranslationInfo_' . $language, $languageTranslationInfo);
}
return $this->languageHasTranslationsCache[$language];
return $languageTranslationInfo;
}
protected function getQueryBuilder(): QueryBuilder
......@@ -207,7 +210,7 @@ class ContentFetcher
$queryBuilder->andWhere(
$queryBuilder->expr()->eq(
'tt_content.pid',
$queryBuilder->createNamedParameter($this->backendLayout->getDrawingConfiguration()->getPageId(), \PDO::PARAM_INT)
$queryBuilder->createNamedParameter($this->context->getPageId(), \PDO::PARAM_INT)
)
);
......@@ -224,7 +227,7 @@ class ContentFetcher
$hookObject->modifyQuery(
$parameters,
'tt_content',
$this->backendLayout->getDrawingConfiguration()->getPageId(),
$this->context->getPageId(),
$additionalConstraints,
$fields,
$queryBuilder
......@@ -251,4 +254,9 @@ class ContentFetcher
{
return $GLOBALS['LANG'];
}
protected function getRuntimeCache(): VariableFrontend
{
return GeneralUtility::makeInstance(CacheManager::class)->getCache('cache_runtime');
}
}
......@@ -17,7 +17,7 @@ declare(strict_types=1);
namespace TYPO3\CMS\Backend\View\BackendLayout\Grid;
use TYPO3\CMS\Backend\View\BackendLayout\BackendLayout;
use TYPO3\CMS\Backend\View\PageLayoutContext;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Localization\LanguageService;
......@@ -38,9 +38,9 @@ use TYPO3\CMS\Core\Utility\StringUtility;
abstract class AbstractGridObject
{
/**
* @var BackendLayout
* @var PageLayoutContext
*/
protected $backendLayout;
protected $context;
/**
* @var IconFactory
......@@ -52,9 +52,9 @@ abstract class AbstractGridObject
*/
protected $uniqueId;
public function __construct(BackendLayout $backendLayout)
public function __construct(PageLayoutContext $context)
{
$this->backendLayout = $backendLayout;
$this->context = $context;
$this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
}
......@@ -63,9 +63,9 @@ abstract class AbstractGridObject
return $this->uniqueId ?? $this->uniqueId = StringUtility::getUniqueId();
}
public function getBackendLayout(): BackendLayout
public function getContext(): PageLayoutContext
{
return $this->backendLayout;
return $this->context;
}
protected function getLanguageService(): LanguageService
......
......@@ -67,19 +67,9 @@ class Grid extends AbstractGridObject
return $columns;
}
public function isAllowNewContent(): bool
{
return $this->allowNewContent;
}
public function setAllowNewContent(bool $allowNewContent): void
{
$this->allowNewContent = $allowNewContent;
}
public function getSpan(): int
{
if (!isset($this->rows[0]) || $this->backendLayout->getDrawingConfiguration()->getLanguageMode()) {
if (!isset($this->rows[0]) || $this->context->getDrawingConfiguration()->getLanguageMode()) {
return 1;
}
$span = 0;
......
......@@ -19,7 +19,7 @@ namespace TYPO3\CMS\Backend\View\BackendLayout\Grid;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\View\BackendLayout\BackendLayout;
use TYPO3\CMS\Backend\View\PageLayoutContext;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -67,31 +67,19 @@ class GridColumn extends AbstractGridObject
*/