Skip to content

Commit

Permalink
Merge pull request #16 from techdivision/task/prevent-deep-content-ne…
Browse files Browse the repository at this point in the history
…sting

TASK // Prevent deep content nesting and refactor structure
  • Loading branch information
FlorianHartl authored Apr 2, 2024
2 parents a2f0749 + f363c76 commit 42c7c64
Show file tree
Hide file tree
Showing 47 changed files with 1,443 additions and 306 deletions.
34 changes: 16 additions & 18 deletions Classes/Eel/CssClassMappingHelper.php
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
<?php
declare(strict_types = 1);
declare(strict_types=1);

namespace TechDivision\NodeTypes\FlexColumnLayouts\Eel;

/**
* This file is part of the TechDivision.NodeTypes.FlexColumnLayouts package.
*
* TechDivision - neos@techdivision.com
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/

use Neos\Flow\Annotations as Flow;
use Neos\Eel\ProtectedContextAwareInterface;


/*
* This file is part of the TechDivision.NodeTypes.FlexColumnLayouts package.
*
* TechDivision - neos@techdivision.com
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/

class CssClassMappingHelper implements ProtectedContextAwareInterface
{
/**
* @var array
* @Flow\InjectConfiguration("cssClassMapping")
*/
protected $cssClassMapping;
protected array $cssClassMapping;

/**
* replaces class values from class string with according css classes from
* other frameworks
*
* @param string $concatenatedCssClasses
* @param string $configurationKey
* @return string
*/
public function replace($concatenatedCssClasses, $configurationKey): string
public function replace(string $concatenatedCssClasses, string $configurationKey): string
{
if (array_key_exists($configurationKey, $this->cssClassMapping) === false) {
return $concatenatedCssClasses;
Expand All @@ -43,7 +43,7 @@ public function replace($concatenatedCssClasses, $configurationKey): string
$replacedCssClasses = [];

foreach ($cssClasses as $cssClass) {
if (trim($cssClass) === ''){
if (trim($cssClass) === '') {
continue;
}
if (array_key_exists($cssClass, $replacements)) {
Expand All @@ -59,12 +59,10 @@ public function replace($concatenatedCssClasses, $configurationKey): string

/**
* @param string $methodName
*
* @return boolean
*/
public function allowsCallOfMethod($methodName): bool
{
return true;
}

}
}
39 changes: 0 additions & 39 deletions Configuration/NodeTypes.Content.OneColumn.yaml

This file was deleted.

48 changes: 0 additions & 48 deletions Configuration/NodeTypes.FlexCollection.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions Configuration/NodeTypes.Override.Content.Column.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ TechDivision:
FlexColumnLayouts:
cssClassMapping:
bootstrap:

'flex': 'd-flex'

'flex-col': 'flex-column'
Expand Down Expand Up @@ -115,7 +114,6 @@ TechDivision:
'lg:items-center': 'align-items-lg-center'
'xl:items-center': 'align-items-xl-center'


#ADVANCED Configuration/NodeTypes.FlexCollection.yaml properties

'content-between': 'align-content-between'
Expand Down
4 changes: 4 additions & 0 deletions Configuration/Settings.Fusion.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Neos:
Fusion:
defaultContext:
'CssClassMapping': 'TechDivision\NodeTypes\FlexColumnLayouts\Eel\CssClassMappingHelper'
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,3 @@ Neos:
TechDivision.NodeTypes.FlexColumnLayouts:
- 'Main'
- 'NodeTypes/*'
Fusion:
defaultContext:
'CssClassMapping': 'TechDivision\NodeTypes\FlexColumnLayouts\Eel\CssClassMappingHelper'
85 changes: 28 additions & 57 deletions Migrations/ContentRepository/Version20200904150412.yaml
Original file line number Diff line number Diff line change
@@ -1,119 +1,90 @@
up:
comments: 'This migration changes all your existing grid columns'
migration:
-
filters:
-
type: 'NodeType'
- filters:
- type: 'NodeType'
settings:
nodeType: 'Neos.Neos:ContentCollection'
-
type: 'NodeName'
- type: 'NodeName'
settings:
nodeName: 'column0'

transformations:
-
type: 'ChangeNodeType'
- type: 'ChangeNodeType'
settings:
newType: 'TechDivision.NodeTypes.FlexColumnLayouts:FlexCollection.FirstColumn'
-
filters:
-
type: 'NodeType'
- filters:
- type: 'NodeType'
settings:
nodeType: 'Neos.Neos:ContentCollection'
-
type: 'NodeName'
- type: 'NodeName'
settings:
nodeName: 'column1'

transformations:
-
type: 'ChangeNodeType'
- type: 'ChangeNodeType'
settings:
newType: 'TechDivision.NodeTypes.FlexColumnLayouts:FlexCollection.SecondColumn'
-
filters:
-
type: 'NodeType'
- filters:
- type: 'NodeType'
settings:
nodeType: 'Neos.Neos:ContentCollection'
-
type: 'NodeName'
- type: 'NodeName'
settings:
nodeName: 'column2'

transformations:
-
type: 'ChangeNodeType'
- type: 'ChangeNodeType'
settings:
newType: 'TechDivision.NodeTypes.FlexColumnLayouts:FlexCollection.ThirdColumn'
-
filters:
-
type: 'NodeType'
- filters:
- type: 'NodeType'
settings:
nodeType: 'Neos.Neos:ContentCollection'
-
type: 'NodeName'
- type: 'NodeName'
settings:
nodeName: 'column3'

transformations:
-
type: 'ChangeNodeType'
- type: 'ChangeNodeType'
settings:
newType: 'TechDivision.NodeTypes.FlexColumnLayouts:FlexCollection.FourthColumn'

down:
migration:
-
filters:
-
type: 'NodeType'
- filters:
- type: 'NodeType'
settings:
nodeType: 'TechDivision.NodeTypes.FlexColumnLayouts:FlexCollection.FirstColumn'

transformations:
-
type: 'ChangeNodeType'
- type: 'ChangeNodeType'
settings:
newType: 'Neos.Neos:ContentCollection'
-
filters:
-
type: 'NodeType'
- filters:
- type: 'NodeType'
settings:
nodeType: 'TechDivision.NodeTypes.FlexColumnLayouts:FlexCollection.SecondColumn'

transformations:
-
type: 'ChangeNodeType'
- type: 'ChangeNodeType'
settings:
newType: 'Neos.Neos:ContentCollection'
-
filters:
-
type: 'NodeType'
- filters:
- type: 'NodeType'
settings:
nodeType: 'TechDivision.NodeTypes.FlexColumnLayouts:FlexCollection.ThirdColumn'

transformations:
-
type: 'ChangeNodeType'
- type: 'ChangeNodeType'
settings:
newType: 'Neos.Neos:ContentCollection'
-
filters:
-
type: 'NodeType'
- filters:
- type: 'NodeType'
settings:
nodeType: 'TechDivision.NodeTypes.FlexColumnLayouts:FlexCollection.FourthColumn'

transformations:
-
type: 'ChangeNodeType'
- type: 'ChangeNodeType'
settings:
newType: 'Neos.Neos:ContentCollection'

37 changes: 37 additions & 0 deletions NodeTypes/Content/OneColumn.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
'TechDivision.NodeTypes.FlexColumnLayouts:OneColumn':
superTypes:
'Neos.NodeTypes.ColumnLayouts:Column': true
'Neos.Neos:ContentCollection': true
ui:
label: 'One column content'
position: 100
properties:
layout:
defaultValue: '100'
ui:
reloadIfChanged: true
inspector:
editorOptions:
values:
'100':
label: '100%'
flexDirection: []
flexWrap: []
flexAlignItems: []
flexAlignContent: []
smFlexDirection: []
smFlexWrap: []
smFlexAlignItems: []
smFlexAlignContent: []
mdFlexDirection: []
mdFlexWrap: []
mdFlexAlignItems: []
mdFlexAlignContent: []
lgFlexDirection: []
lgFlexWrap: []
lgFlexAlignItems: []
lgFlexAlignContent: []
xlFlexDirection: []
xlFlexWrap: []
xlFlexAlignItems: []
xlFlexAlignContent: []
Loading

0 comments on commit 42c7c64

Please sign in to comment.