[TYPO3-mvc] Object accessor containing object accessors

Laurent Foulloy yolf.typo3 at orange.fr
Fri Aug 13 11:34:31 CEST 2010


Hi all,

I'm back with this problem of having object accessors containing object 
accessors e.g {a.{b.c}.d} :

It can be achieved by slightly modifying the pattern 
$SCAN_PATTERN_SHORTHANDSYNTAX_OBJECTACCESSORS in 
Tx_Fluid_Core_Parser_TemplateParser by adding {} in 
P<Object>[a-zA-Z0-9\-_.], that is P<Object>[a-zA-Z0-9\-_.{}].

Then, a small modification is needed in the method evaluate() in 
Tx_Fluid_Core_Parser_SyntaxTree_ObjectAccessorNode to parse the inner 
accessors

public function evaluate() {
   // Added to parse the inner accessors if any
   if 
(preg_match('/^(?P<Start>[^{]*)(?P<ObjectAccesor>{.*})(?P<End>[^}]*)$/', 
$this->objectPath, $matchedVariables) > 0) {
     $templateParser = 
Tx_Fluid_Compatibility_TemplateParserBuilder::build();
     $parsedTemplate = 
$templateParser->parse($matchedVariables['ObjectAccesor']);
     $this->objectPath = $matchedVariables['Start'] . 
$parsedTemplate->render($this->renderingContext) . $matchedVariables['End'];
     }

   $objectPathParts = explode('.', $this->objectPath);

Any better idea ?

Best regards

Laurent


More information about the TYPO3-project-typo3v4mvc mailing list