Ejemplo n.º 1
0
 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");
     }
 }
Ejemplo n.º 2
0
 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);
     }
 }
Ejemplo n.º 3
0
 function testGenerateExpressionWithLocalVariableModifierWithPath()
 {
     $code_writer = new WactCodeWriter();
     $root = new WactCompileTreeRootNode();
     $context = new WactCompileTreeNode();
     $context->parent = $root;
     $DBE = new WactDataBindingExpressionNode('$Test.var', $context);
     $DBE->generatePreStatement($code_writer);
     $DBE->generateExpression($code_writer);
     $DBE->generatePostStatement($code_writer);
     $this->assertEqual($code_writer->getCode(), '<?php WactTemplate::getValue($Test,\'var\')');
 }