コード例 #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");
     }
 }
コード例 #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);
     }
 }
コード例 #3
0
 function testGenerateExpressionWithContextModifierAndNoFieldName()
 {
     $context = new WactCompileTreeRootNode();
     $child1 = new MockWactCompileTreeNode();
     $child1->setReturnValue('isDataSource', true);
     $child1->setReturnValue('getServerId', 'child1');
     $child1->setReturnValue('getComponentRefCode', '$components["A"]');
     $context->addChild($child1);
     $DBE = new WactDataBindingExpressionNode('[child1]', $context);
     $DBE->analyzeExpression();
     $this->assertFalse($DBE->isConstant());
     $this->assertFalse($DBE->getFieldName());
     $code_writer = new WactCodeWriter();
     $DBE->generateExpression($code_writer);
     $this->assertEqual($code_writer->getCode(), '<?php $components["A"]');
 }