Skip to content

Instantly share code, notes, and snippets.

@Nikdro
Last active March 22, 2017 11:32
Show Gist options
  • Save Nikdro/d0a18623096cf9cb8ff720263ada046b to your computer and use it in GitHub Desktop.
Save Nikdro/d0a18623096cf9cb8ff720263ada046b to your computer and use it in GitHub Desktop.
Neos: This class implements \TYPO3\Flow\Property\PropertyMapper into TypoScript2 / Fusion
<?php
namespace KaufmannDigital\Neos\Base\Eel\Helper;
use TYPO3\Flow\Annotations as Flow;
use TYPO3\Eel\ProtectedContextAwareInterface;
use TYPO3\Flow\Property\PropertyMapper;
/**
* Class PropertyMapperHelper
*
* This class implements \TYPO3\Flow\Property\PropertyMapper into TypoScript2 / Fusion
* Example usage (Fusion): myObject = ${PropertyMapper.convert(request.arguments.myObject, 'My\Namespace\And\ClassName')}
*
* @author Niklas Droste <[email protected]>
*/
class PropertyMapperHelper implements ProtectedContextAwareInterface
{
/**
* @Flow\Inject
* @var PropertyMapper
*/
protected $propertyMapper;
/**
* @param mixed $source
* @param string $targetType
* @return mixed
*/
public function convert($source, $targetType)
{
return $this->propertyMapper->convert($source, $targetType);
}
/**
* @param string $methodName
* @return bool
*/
public function allowsCallOfMethod($methodName)
{
return true;
}
}
TYPO3:
TypoScript:
defaultContext:
'PropertyMapper': 'Package\Vendor\Eel\Helper\PropertyMapperHelper'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment