Skip to content

Commit

Permalink
[REMOVAL] Remove provider-resolving proxy methods from FluxService
Browse files Browse the repository at this point in the history
  • Loading branch information
NamelessCoder committed Aug 12, 2023
1 parent dfaa3a4 commit 2e5818a
Show file tree
Hide file tree
Showing 27 changed files with 239 additions and 298 deletions.
12 changes: 6 additions & 6 deletions Classes/Backend/BackendLayoutDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

use FluidTYPO3\Flux\Provider\PageProvider;
use FluidTYPO3\Flux\Provider\ProviderInterface;
use FluidTYPO3\Flux\Service\FluxService;
use FluidTYPO3\Flux\Provider\ProviderResolver;
use FluidTYPO3\Flux\Service\WorkspacesAwareRecordService;
use TYPO3\CMS\Backend\View\BackendLayout\BackendLayout;
use TYPO3\CMS\Backend\View\BackendLayout\BackendLayoutCollection;
Expand All @@ -22,14 +22,14 @@

class BackendLayoutDataProvider extends DefaultDataProvider implements DataProviderInterface
{
protected FluxService $configurationService;
protected ProviderResolver $providerResolver;
protected WorkspacesAwareRecordService $recordService;

public function __construct()
{
/** @var FluxService $fluxService */
$fluxService = GeneralUtility::makeInstance(FluxService::class);
$this->configurationService = $fluxService;
/** @var ProviderResolver $providerResolver */
$providerResolver = GeneralUtility::makeInstance(ProviderResolver::class);
$this->providerResolver = $providerResolver;

/** @var WorkspacesAwareRecordService $workspacesAwareRecordService */
$workspacesAwareRecordService = GeneralUtility::makeInstance(WorkspacesAwareRecordService::class);
Expand Down Expand Up @@ -76,7 +76,7 @@ protected function resolveProvider(array $record): ?ProviderInterface
return null;
}

return $this->configurationService->resolvePageProvider($record);
return $this->providerResolver->resolvePageProvider($record);
}

/**
Expand Down
16 changes: 9 additions & 7 deletions Classes/Builder/FlexFormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,23 @@
use FluidTYPO3\Flux\Form;
use FluidTYPO3\Flux\Provider\Interfaces\DataStructureProviderInterface;
use FluidTYPO3\Flux\Provider\Interfaces\FormProviderInterface;
use FluidTYPO3\Flux\Provider\ProviderResolver;
use FluidTYPO3\Flux\Service\CacheService;
use FluidTYPO3\Flux\Service\FluxService;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;

class FlexFormBuilder
{
protected FluxService $configurationService;
protected CacheService $cacheService;
protected ProviderResolver $providerResolver;

public function __construct(FluxService $fluxService, CacheService $cacheService)
{
$this->configurationService = $fluxService;
public function __construct(
CacheService $cacheService,
ProviderResolver $providerResolver
) {
$this->cacheService = $cacheService;
$this->providerResolver = $providerResolver;
}

public function resolveDataStructureIdentifier(
Expand Down Expand Up @@ -62,7 +64,7 @@ public function resolveDataStructureIdentifier(
$limitedRecordData = array_intersect_key($record, $fields);
$limitedRecordData[$fieldName] = $record[$fieldName];
}
$provider = $this->configurationService->resolvePrimaryConfigurationProvider($tableName, $fieldName, $record);
$provider = $this->providerResolver->resolvePrimaryConfigurationProvider($tableName, $fieldName, $record);
if (!$provider) {
return [];
}
Expand Down Expand Up @@ -101,7 +103,7 @@ public function parseDataStructureByIdentifier(array $identifier): array
}
$fieldName = $identifier['fieldName'];
$dataStructArray = [];
$provider = $this->configurationService->resolvePrimaryConfigurationProvider(
$provider = $this->providerResolver->resolvePrimaryConfigurationProvider(
$identifier['tableName'],
$fieldName,
$record,
Expand Down
23 changes: 14 additions & 9 deletions Classes/Controller/AbstractFluxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
use FluidTYPO3\Flux\Builder\RequestBuilder;
use FluidTYPO3\Flux\Hooks\HookHandler;
use FluidTYPO3\Flux\Integration\NormalizedData\DataAccessTrait;
use FluidTYPO3\Flux\Integration\Resolver;
use FluidTYPO3\Flux\Provider\Interfaces\ControllerProviderInterface;
use FluidTYPO3\Flux\Provider\Interfaces\DataStructureProviderInterface;
use FluidTYPO3\Flux\Provider\Interfaces\FluidProviderInterface;
use FluidTYPO3\Flux\Provider\ProviderResolver;
use FluidTYPO3\Flux\Service\FluxService;
use FluidTYPO3\Flux\Service\TypoScriptService;
use FluidTYPO3\Flux\Service\WorkspacesAwareRecordService;
Expand Down Expand Up @@ -60,20 +62,26 @@ abstract class AbstractFluxController extends ActionController
protected FluxService $configurationService;
protected WorkspacesAwareRecordService $recordService;
protected TypoScriptService $typoScriptService;
protected ProviderResolver $providerResolver;
protected Resolver $resolver;
protected ?ControllerProviderInterface $provider = null;

public function __construct(
FluxService $fluxService,
RenderingContextBuilder $renderingContextBuilder,
RequestBuilder $requestBuilder,
WorkspacesAwareRecordService $recordService,
TypoScriptService $typoScriptService
TypoScriptService $typoScriptService,
ProviderResolver $providerResolver,
Resolver $resolver
) {
$this->configurationService = $fluxService;
$this->renderingContextBuilder = $renderingContextBuilder;
$this->requestBuilder = $requestBuilder;
$this->recordService = $recordService;
$this->typoScriptService = $typoScriptService;
$this->providerResolver = $providerResolver;
$this->resolver = $resolver;

/** @var Arguments $arguments */
$arguments = GeneralUtility::makeInstance(Arguments::class);
Expand Down Expand Up @@ -155,7 +163,7 @@ protected function initializeProvider(): void
$row = $this->getRecord();
$table = (string) $this->getFluxTableName();
$field = $this->getFluxRecordField();
$provider = $this->configurationService->resolvePrimaryConfigurationProvider(
$provider = $this->providerResolver->resolvePrimaryConfigurationProvider(
$table,
$field,
$row,
Expand Down Expand Up @@ -244,7 +252,7 @@ protected function resolveView(): \TYPO3Fluid\Fluid\View\ViewInterface

$renderingContext = $this->renderingContextBuilder->buildRenderingContextFor(
$extensionName,
$this->configurationService->getResolver()->resolveControllerNameFromControllerClassName(get_class($this)),
$this->resolver->resolveControllerNameFromControllerClassName(get_class($this)),
$controllerActionName,
$this->provider->getPluginName() ?? $this->provider->getControllerNameFromRecord($record)
);
Expand Down Expand Up @@ -395,9 +403,7 @@ protected function performSubRendering(
}
$content = $this->view->render();
} else {
$foreignControllerClass = $this->configurationService
->getResolver()
->resolveFluxControllerClassNameByExtensionKeyAndControllerName(
$foreignControllerClass = $this->resolver->resolveFluxControllerClassNameByExtensionKeyAndControllerName(
$extensionName,
$controllerName
);
Expand Down Expand Up @@ -430,8 +436,7 @@ protected function hasSubControllerActionOnForeignController(
string $controllerName,
string $actionName
): bool {
$potentialControllerClassName = $this->configurationService->getResolver()
->resolveFluxControllerClassNameByExtensionKeyAndControllerName(
$potentialControllerClassName = $this->resolver->resolveFluxControllerClassNameByExtensionKeyAndControllerName(
$extensionName,
$controllerName
);
Expand All @@ -457,7 +462,7 @@ protected function callSubControllerAction(
$arguments = $this->getServerRequest()->getQueryParams()[$pluginSignature] ?? [];
$request = $this->requestBuilder->buildRequestFor(
$extensionName,
$this->configurationService->getResolver()->resolveControllerNameFromControllerClassName(
$this->resolver->resolveControllerNameFromControllerClassName(
$controllerClassName
),
$controllerActionName,
Expand Down
12 changes: 6 additions & 6 deletions Classes/Integration/HookSubscribers/ContentIcon.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use FluidTYPO3\Flux\Hooks\HookHandler;
use FluidTYPO3\Flux\Provider\Interfaces\GridProviderInterface;
use FluidTYPO3\Flux\Service\FluxService;
use FluidTYPO3\Flux\Provider\ProviderResolver;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\View\BackendLayout\Grid\GridColumnItem;
use TYPO3\CMS\Backend\View\PageLayoutView;
Expand Down Expand Up @@ -38,15 +38,15 @@ class ContentIcon
</div></div><div>',
];

protected FluxService $fluxService;
protected ProviderResolver $providerResolver;
protected IconFactory $iconFactory;
protected FrontendInterface $cache;

public function __construct()
{
/** @var FluxService $fluxService */
$fluxService = GeneralUtility::makeInstance(FluxService::class);
$this->fluxService = $fluxService;
/** @var ProviderResolver $providerResolver */
$providerResolver = GeneralUtility::makeInstance(ProviderResolver::class);
$this->providerResolver = $providerResolver;

/** @var IconFactory $iconFactory */
$iconFactory = GeneralUtility::makeInstance(IconFactory::class);
Expand Down Expand Up @@ -92,7 +92,7 @@ public function addSubIcon(array $parameters, $caller = null): string
// filter 2: table must have one field defined as "flex" and record must include it.
if ($field && array_key_exists($field, $record)) {
/** @var GridProviderInterface $provider */
$provider = $this->fluxService->resolvePrimaryConfigurationProvider(
$provider = $this->providerResolver->resolvePrimaryConfigurationProvider(
$table,
$field,
$record,
Expand Down
8 changes: 4 additions & 4 deletions Classes/Integration/Overrides/BackendLayoutView.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

use FluidTYPO3\Flux\Integration\FormEngine\SelectOption;
use FluidTYPO3\Flux\Provider\Interfaces\GridProviderInterface;
use FluidTYPO3\Flux\Service\FluxService;
use FluidTYPO3\Flux\Provider\ProviderResolver;
use FluidTYPO3\Flux\Utility\ColumnNumberUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand Down Expand Up @@ -158,9 +158,9 @@ protected function loadRecordFromTable(string $table, int $uid): ?array

protected function resolvePrimaryProviderForRecord(string $table, array $record): ?GridProviderInterface
{
/** @var FluxService $fluxService */
$fluxService = GeneralUtility::makeInstance(FluxService::class);
return $fluxService->resolvePrimaryConfigurationProvider(
/** @var ProviderResolver $providerResolver */
$providerResolver = GeneralUtility::makeInstance(ProviderResolver::class);
return $providerResolver->resolvePrimaryConfigurationProvider(
$table,
null,
$record,
Expand Down
10 changes: 5 additions & 5 deletions Classes/Integration/PreviewRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
*/

use FluidTYPO3\Flux\Provider\ProviderInterface;
use FluidTYPO3\Flux\Service\FluxService;
use FluidTYPO3\Flux\Provider\ProviderResolver;
use TYPO3\CMS\Core\Page\PageRenderer;

class PreviewRenderer
{
protected static bool $assetsIncluded = false;
private PageRenderer $pageRenderer;
private FluxService $fluxService;
private ProviderResolver $providerResolver;

public function __construct(PageRenderer $pageRenderer, FluxService $fluxService)
public function __construct(PageRenderer $pageRenderer, ProviderResolver $providerResolver)
{
$this->pageRenderer = $pageRenderer;
$this->fluxService = $fluxService;
$this->providerResolver = $providerResolver;
}

public function renderPreview(array $row): ?array
Expand All @@ -31,7 +31,7 @@ public function renderPreview(array $row): ?array
$headerContent = null;
$drawItem = true;
$itemContent = '<a name="c' . $row['uid'] . '"></a>';
$providers = $this->fluxService->resolveConfigurationProviders('tt_content', $fieldName, $row);
$providers = $this->providerResolver->resolveConfigurationProviders('tt_content', $fieldName, $row);
foreach ($providers as $provider) {
/** @var ProviderInterface $provider */
[$previewHeader, $previewContent, $continueDrawing] = $provider->getPreview($row);
Expand Down
12 changes: 6 additions & 6 deletions Classes/Integration/WizardItemsManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use FluidTYPO3\Flux\Content\ContentTypeManager;
use FluidTYPO3\Flux\Form\FormInterface;
use FluidTYPO3\Flux\Hooks\HookHandler;
use FluidTYPO3\Flux\Service\FluxService;
use FluidTYPO3\Flux\Provider\ProviderResolver;
use FluidTYPO3\Flux\Service\WorkspacesAwareRecordService;
use FluidTYPO3\Flux\Utility\ColumnNumberUtility;
use TYPO3\CMS\Core\Exception\SiteNotFoundException;
Expand All @@ -14,18 +14,18 @@

class WizardItemsManipulator
{
protected FluxService $configurationService;
protected ProviderResolver $providerResolver;
protected WorkspacesAwareRecordService $recordService;
protected ContentTypeManager $contentTypeManager;
protected SiteFinder $siteFinder;

public function __construct(
FluxService $fluxService,
ProviderResolver $providerResolver,
WorkspacesAwareRecordService $recordService,
ContentTypeManager $contentTypeManager,
SiteFinder $siteFinder
) {
$this->configurationService = $fluxService;
$this->providerResolver = $providerResolver;
$this->recordService = $recordService;
$this->contentTypeManager = $contentTypeManager;
$this->siteFinder = $siteFinder;
Expand Down Expand Up @@ -103,7 +103,7 @@ protected function getWhiteAndBlackListsFromPageAndContentColumn(int $pageUid, i
// returned contains a Column which matches the desired colPos value, attempt to read a list
// of allowed/denied content element types from it.
$pageRecord = (array) $this->recordService->getSingle('pages', '*', $pageUid);
$pageProviders = $this->configurationService->resolveConfigurationProviders('pages', null, $pageRecord);
$pageProviders = $this->providerResolver->resolveConfigurationProviders('pages', null, $pageRecord);
$parentRecordUid = ColumnNumberUtility::calculateParentUid($columnPosition);
$pageColumnPosition = $parentRecordUid > 0
? $this->findParentColumnPosition($parentRecordUid)
Expand All @@ -127,7 +127,7 @@ protected function getWhiteAndBlackListsFromPageAndContentColumn(int $pageUid, i
// a page template like above; it's the same principle).
if ($parentRecordUid > 0) {
$parentRecord = (array) $this->recordService->getSingle('tt_content', '*', $parentRecordUid);
$contentProviders = $this->configurationService->resolveConfigurationProviders(
$contentProviders = $this->providerResolver->resolveConfigurationProviders(
'tt_content',
null,
$parentRecord
Expand Down
12 changes: 12 additions & 0 deletions Classes/Provider/ProviderResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ public function __construct(TypoScriptService $typoScriptService)
$this->typoScriptService = $typoScriptService;
}

/**
* Resolve fluidpages specific configuration provider. Always
* returns the main PageProvider type which needs to be used
* as primary PageProvider when processing a complete page
* rather than just the "sub configuration" field value.
*/
public function resolvePageProvider(array $row): ?ProviderInterface
{
$provider = $this->resolvePrimaryConfigurationProvider('pages', PageProvider::FIELD_NAME_MAIN, $row);
return $provider;
}

/**
* ResolveUtility the top-priority ConfigurationPrivider which can provide
* a working FlexForm configuration baed on the given parameters.
Expand Down
Loading

0 comments on commit 2e5818a

Please sign in to comment.