function generateBeforeContent($code_writer) { foreach ($this->_getExpressionsInTargetAttribute() as $expression) { $dbe = new WactDataBindingExpressionNode($expression, $this, $this->parent); $datasource = $dbe->getDatasourceContext(); $field_name = $dbe->getFieldName(); if ($field_name && !$datasource->isDatasource()) { $this->raiseCompilerError('Wrong datasource path in target or to attribute', array('expression' => $expression)); } if (count($dbe->getPathToTargetDatasource())) { $this->raiseCompilerError('Path based variable is not supported in target or to attribute', array('expression' => $expression)); } $code_writer->writePHP($datasource->getComponentRefCode() . '->registerDatasource('); $this->attributeNodes['from']->generateExpression($code_writer); $code_writer->writePHP(');' . "\n"); } }
protected function _processTargetAttribute($code_writer) { foreach ($this->_getExpressionsFromTargetAttribute() as $expression) { $dbe = new WactDataBindingExpressionNode($expression, $this, $this->parent); $datasource = $dbe->getDatasourceContext(); $field_name = $dbe->getFieldName(); if ($field_name && !$datasource->isDatasource()) { $this->raiseCompilerError('Wrong DBE datasource context in buffer attribute', array('expression' => $expression)); } if (count($dbe->getPathToTargetDatasource())) { $this->raiseCompilerError('Path based variable name is not supported in buffer attribute', array('expression' => $expression)); } $dbe->generatePreStatement($code_writer); $code_writer->writePHP($this->getComponentRefCode() . '->addBuffer('); $code_writer->writePHP($datasource->getComponentRefCode()); if ($field_name) { $code_writer->writePHP(', "' . $field_name . '"'); } $code_writer->writePHP(');' . "\n"); $dbe->generatePostStatement($code_writer); } }
function testAnalizeExpressionWithChildModifier() { $parent = new WactCompileTreeRootNode(); $child = new WactCompileTreeRootNode(); $child->setServerId('child'); $child->parent = $parent; $parent->addChild($child); $DBE = new WactDataBindingExpressionNode('[child]', $parent); $DBE->prepare(); $this->assertNull($DBE->getFieldName()); $this->assertReference($DBE->getDatasourceContext(), $child); }