This repository has been archived by the owner on Sep 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from PackageFactory/feature/addAugmenterPrototype
FEATURE: Add `PackageFactory.AtomicFusion:Augmenter` fusion-prototype
- Loading branch information
Showing
3 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
Classes/PackageFactory/AtomicFusion/FusionObjects/AugmenterImplementation.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
namespace PackageFactory\AtomicFusion\FusionObjects; | ||
|
||
/** | ||
* This file is part of the PackageFactory.AtomicFusion package | ||
* | ||
* (c) 2016 | ||
* Wilhelm Behncke <wilhelm.behncke@googlemail.com> | ||
* Martin Ficzel <martin.ficzel@gmx.de> | ||
* | ||
* 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\Fusion\FusionObjects\ArrayImplementation; | ||
use Neos\Neos\Service\HtmlAugmenter; | ||
|
||
/** | ||
* A Fusion Augmenter-Object | ||
* | ||
* The fusion object can be used to add html-attributes to the rendererd content | ||
* | ||
* @api | ||
*/ | ||
class AugmenterImplementation extends ArrayImplementation | ||
{ | ||
|
||
/** | ||
* @var HtmlAugmenter | ||
* @Flow\Inject | ||
*/ | ||
protected $htmlAugmenter; | ||
|
||
/** | ||
* Properties that are ignored | ||
* | ||
* @var array | ||
*/ | ||
protected $ignoreProperties = ['__meta', 'fallbackTagName', 'content']; | ||
|
||
/** | ||
* @return void|string | ||
*/ | ||
public function evaluate() | ||
{ | ||
$content = $this->fusionValue('content'); | ||
$fallbackTagName = $this->fusionValue('fallbackTagName'); | ||
|
||
$sortedChildFusionKeys = $this->sortNestedFusionKeys(); | ||
|
||
$attributes = []; | ||
foreach ($sortedChildFusionKeys as $key) { | ||
if ($fusionValue = $this->fusionValue($key)) { | ||
$attributes[$key] = $fusionValue; | ||
} | ||
} | ||
|
||
if ($attributes && is_array($attributes) && count($attributes) > 0) { | ||
return $this->htmlAugmenter->addAttributes($content, $attributes, $fallbackTagName); | ||
} else { | ||
return $content; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
prototype(PackageFactory.AtomicFusion:Augmenter) < prototype(PackageFactory.AtomicFusion:Component) { | ||
@class = 'PackageFactory\\AtomicFusion\\FusionObjects\\AugmenterImplementation' | ||
|
||
fallbackTagName = "div" | ||
content = ${value} | ||
} |