Skip to content

Commit

Permalink
[TASK] Refactor support for structure elements
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Büchler committed Nov 10, 2021
1 parent bb359d0 commit 0985fd3
Show file tree
Hide file tree
Showing 39 changed files with 6,222 additions and 443 deletions.
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,8 @@ indent_style = tab
[*.sql]
indent_style = tab
indent_size = 2

# neon-Files
[*.neon]
indent_style = tab
indent_size = 4
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ jobs:
max-parallel: 4
matrix:
typo3: [ '^10', '^11' ]
php: [ '7.2', '7.3', '7.4' ]
php: [ '7.3', '7.4' ]
mysql: [ '5.7' ]
exclude:
- typo3: '^11'
php: '7.2'
- typo3: '^11'
php: '7.3'
steps:
Expand Down
4 changes: 2 additions & 2 deletions Build/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ parameters:
count: 1
path: ../Classes/ViewHelpers/Structure/VariantsViewHelper.php
-
message: "#^Return type \\(mixed\\) of method Buepro\\\\Pizpalue\\\\ViewHelpers\\\\Structure\\\\VariantsModifierStackViewHelper\\:\\:renderStatic\\(\\) should be covariant with return type \\(string\\) of method TYPO3Fluid\\\\Fluid\\\\Core\\\\ViewHelper\\\\ViewHelperInterface\\:\\:renderStatic\\(\\)$#"
message: "#^Return type \\(mixed\\) of method Buepro\\\\Pizpalue\\\\ViewHelpers\\\\Structure\\\\ModificationStackViewHelper\\:\\:renderStatic\\(\\) should be covariant with return type \\(string\\) of method TYPO3Fluid\\\\Fluid\\\\Core\\\\ViewHelper\\\\ViewHelperInterface\\:\\:renderStatic\\(\\)$#"
count: 1
path: ../Classes/ViewHelpers/Structure/VariantsModifierStackViewHelper.php
path: ../Classes/ViewHelpers/Structure/ModificationStackViewHelper.php
-
message: "#^Return type \\(mixed\\) of method Buepro\\\\Pizpalue\\\\ViewHelpers\\\\Structure\\\\Multiplier\\\\GetForColumnViewHelper\\:\\:renderStatic\\(\\) should be covariant with return type \\(string\\) of method TYPO3Fluid\\\\Fluid\\\\Core\\\\ViewHelper\\\\ViewHelperInterface\\:\\:renderStatic\\(\\)$#"
count: 1
Expand Down
6 changes: 6 additions & 0 deletions Build/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ parameters:
checkMissingIterableValueType: false
reportUnmatchedIgnoredErrors: false

ignoreErrors:
- "#^Constant ORIGINAL_ROOT not found.$#"
- "#^Call to an undefined method Prophecy\\\\Prophecy\\\\ObjectProphecy#"

paths:
- %currentWorkingDirectory%/Classes/Structure/
- %currentWorkingDirectory%/Classes/Utility/
- %currentWorkingDirectory%/Classes/ViewHelpers/
- %currentWorkingDirectory%/Configuration/
- %currentWorkingDirectory%/Tests/
2 changes: 1 addition & 1 deletion Build/phpunit-functional.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<testsuite name="buepro-grevman-functional-tests">
<directory>../Tests/Functional</directory>
<!-- <file>-->
<!-- ../Tests/Functional/ViewHelpers/Data/ImageVariantsViewHelperTest.php-->
<!-- ../Tests/Functional/Structure/VariantsModifierStackTest.php-->
<!-- </file>-->
</testsuite>
</testsuites>
Expand Down
32 changes: 32 additions & 0 deletions Build/phpunit-unit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="true"
bootstrap="../.build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false"
beStrictAboutTestsThatDoNotTestAnything="true"
>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">../Classes/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="buepro-grevman-unit-tests">
<directory>../Tests/Unit</directory>
<!-- <file>-->
<!-- ../Tests/Unit/Structure/VariantsModifierStackTest.php-->
<!-- </file>-->
</testsuite>
</testsuites>
</phpunit>
4 changes: 2 additions & 2 deletions Classes/DataProcessing/StructureProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Buepro\Pizpalue\DataProcessing;

use Buepro\Pizpalue\Utility\StructureVariantsUtility;
use Buepro\Pizpalue\Structure\VariantsModifierStack;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface;

Expand All @@ -33,7 +33,7 @@ public function process(
array $processorConfiguration,
array $processedData
) {
StructureVariantsUtility::setContentElementData($processedData['data']);
VariantsModifierStack::setContentElementData($processedData['data']);
return $processedData;
}
}
167 changes: 0 additions & 167 deletions Classes/Domain/Model/VariantsModifier.php

This file was deleted.

26 changes: 8 additions & 18 deletions Classes/Service/BackendlayoutService.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

namespace Buepro\Pizpalue\Service;

use Buepro\Pizpalue\Domain\Model\VariantsModifier;
use Buepro\Pizpalue\Utility\StructureVariantsUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use Buepro\Pizpalue\Structure\TypoScript;
use Buepro\Pizpalue\Structure\VariantsModifier;
use Buepro\Pizpalue\Structure\VariantsModifierStack;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;

class BackendlayoutService
Expand All @@ -30,33 +30,23 @@ class BackendlayoutService
*/
public function pushVariantsModifier(string $content, array $conf)
{
$variantsModifier = GeneralUtility::makeInstance(VariantsModifier::class);
$variantsModifier = new VariantsModifier();
if (isset($conf['backendlayout']) && isset($this->cObj->data['colPos'])) {
$backendlayout = $this->cObj->cObjGetSingle($conf['backendlayout'], $conf['backendlayout.']);
$colPos = (int) $this->cObj->data['colPos'];
$variantsConf = StructureVariantsUtility::getTypoScriptValue(sprintf(
$variantsModification = TypoScript::getVariants(sprintf(
'%s.%s.%s',
'lib.contentElement.settings.responsiveimages.backendlayout',
$backendlayout,
$colPos
));
if ($variantsConf) {
if (isset($variantsConf['multiplier'])) {
$variantsModifier->setMultiplier($variantsConf['multiplier']);
}
if (isset($variantsConf['gutters'])) {
$variantsModifier->setGutter($variantsConf['gutters']);
}
if (isset($variantsConf['corrections'])) {
$variantsModifier->setCorrection($variantsConf['corrections']);
}
}
$variantsModifier->setModification((array)$variantsModification);
}
StructureVariantsUtility::pushVariantsModifier($variantsModifier);
VariantsModifierStack::pushVariantsModifier($variantsModifier);
}

public function popVariantsModifier()
{
StructureVariantsUtility::popVariantsModifier();
VariantsModifierStack::popVariantsModifier();
}
}
18 changes: 8 additions & 10 deletions Classes/Service/ContentElementService.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@

namespace Buepro\Pizpalue\Service;

use BK2K\BootstrapPackage\Utility\ImageVariantsUtility;
use Buepro\Pizpalue\Domain\Model\VariantsModifier;
use Buepro\Pizpalue\Structure\TypoScript;
use Buepro\Pizpalue\Structure\VariantsModifier;
use Buepro\Pizpalue\Structure\VariantsModifierStack;
use Buepro\Pizpalue\Utility\StructureVariantsUtility;
use TYPO3\CMS\Core\Service\FlexFormService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;

/**
* Class VariantsService
*/
class ContentElementService
{
/**
Expand Down Expand Up @@ -70,9 +68,9 @@ public function pushVariantsModifier()
{
$data = $this->cObj->data;
// default variants
$variants = ImageVariantsUtility::getImageVariants();
$variants = StructureVariantsUtility::getStructureVariants();
if ($this->cObj->getCurrentTable() === 'tt_content' && $data['CType']) {
$variantsConf = StructureVariantsUtility::getTypoScriptValue(
$variantsConf = TypoScript::getVariants(
'lib.contentElement.settings.responsiveimages.contentelements.' . $data['CType']
);
if ($variantsConf) {
Expand All @@ -86,13 +84,13 @@ public function pushVariantsModifier()
}
}
}
$variantsModifier = GeneralUtility::makeInstance(VariantsModifier::class);
$variantsModifier = new VariantsModifier();
$variantsModifier->setVariants($variants);
StructureVariantsUtility::pushVariantsModifier($variantsModifier);
VariantsModifierStack::pushVariantsModifier($variantsModifier);
}

public function popVariantsModifier()
{
StructureVariantsUtility::popVariantsModifier();
VariantsModifierStack::popVariantsModifier();
}
}
Loading

0 comments on commit 0985fd3

Please sign in to comment.