Skip to content

Instantly share code, notes, and snippets.

@mficzel
Last active May 25, 2018 16:31
Show Gist options
  • Save mficzel/21bcbfbf6a341e8b2151f40be5c7e2a8 to your computer and use it in GitHub Desktop.
Save mficzel/21bcbfbf6a341e8b2151f40be5c7e2a8 to your computer and use it in GitHub Desktop.
Optimized PreviewPrototypeImplementation
<?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);
}
}
@mficzel
Copy link
Author

mficzel commented May 25, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment