Last active
May 25, 2018 16:31
-
-
Save mficzel/21bcbfbf6a341e8b2151f40be5c7e2a8 to your computer and use it in GitHub Desktop.
Optimized PreviewPrototypeImplementation
This file contains hidden or 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
<?php | |
namespace Sitegeist\Monocle\FusionObjects; | |
/* | |
* This file is part of the Neos.Fusion package. | |
* | |
* (c) Contributors of the Neos Project - www.neos.io | |
* | |
* 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\AbstractFusionObject; | |
use Sitegeist\Monocle\Fusion\FusionView; | |
use Sitegeist\Monocle\Fusion\FusionService; | |
/** | |
* Renderer props for a prototype Object | |
*/ | |
class PreviewPrototypeImplementation extends AbstractFusionObject | |
{ | |
/** | |
* @return string | |
*/ | |
public function getPrototypeName() | |
{ | |
return $this->fusionValue('prototypeName'); | |
} | |
/** | |
* @return string | |
*/ | |
public function getProps() | |
{ | |
return $this->fusionValue('props'); | |
} | |
/** | |
* @return string | |
*/ | |
public function getPropSet() | |
{ | |
return $this->fusionValue('propSet'); | |
} | |
/** | |
* Render a prototype | |
* | |
* @return mixed | |
*/ | |
public function evaluate() | |
{ | |
$prototypeName = $this->getPrototypeName(); | |
$propSet = $this->getPropSet(); | |
if ($propSet) { | |
$fusionPath = sprintf('%1$s/element<%2$s>/__meta/styleguide/props<%2$s>/__meta/styleguide/propSets/%3$s<%2$s>', $this->path, $prototypeName, $propSet); | |
} else { | |
$fusionPath = sprintf('%s1$/element<%2$s>/__meta/styleguide/props<%2$s>', $this->path, $prototypeName); | |
} | |
return $this->runtime->evaluate($fusionPath); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Props + propSets work without instantiating a new runtime. The downside is that editing props is not possible anymore since i have no clue how to inject the props into the fusion path.