コード例 #1
0
ファイル: ClassGenerator.php プロジェクト: rocksolid-tn/pibx
 public function visitStructureElementEnter(PiBX_AST_Tree $tree)
 {
     $name = $tree->getName();
     $parentName = $tree->getParent()->getName();
     $attributeName = $parentName . $name;
     $selectName = ucfirst($parentName) . 'Select';
     $this->currentClassAttributes .= "\tprivate \$" . $attributeName . ";\n";
     $choiceConstant = $parentName . '_' . $name . '_CHOICE';
     $choiceConstant = strtoupper($choiceConstant);
     $setter = PiBX_Binding_Names::createSetterNameFor($tree);
     $getter = PiBX_Binding_Names::createGetterNameFor($tree);
     $methodName = ucfirst($attributeName);
     $methods = "\tpublic function if{$methodName}() {\n" . "\t\treturn \$this->{$parentName}Select == \$this->{$choiceConstant};\n" . "\t}\n";
     $methods .= "\tpublic function {$setter}(\${$attributeName}) {\n" . "\t\t\$this->set{$selectName}(\$this->{$choiceConstant});\n";
     if ($this->doTypeChecks) {
         $methods .= $this->typeChecks->getTypeCheckFor($tree->getType(), $attributeName);
     }
     $methods .= "\t\t\$this->{$attributeName} = \${$attributeName};\n" . "\t}\n";
     $methods .= "\tpublic function {$getter}() {\n" . "\t\treturn \$this->{$attributeName};\n" . "\t}\n";
     $this->currentClassMethods .= $methods;
     return true;
 }
コード例 #2
0
ファイル: Names.php プロジェクト: rocksolid-tn/pibx
 public static function createTestFunctionFor(PiBX_AST_Tree $tree)
 {
     if ($tree instanceof PiBX_AST_StructureElement) {
         $structureAst = $tree->getParent();
         $structureName = self::getCamelCasedName($structureAst->getName());
         $elementName = self::getCamelCasedName($tree->getName());
         return 'if' . $structureName . $elementName;
     }
     return '';
 }
コード例 #3
0
ファイル: Creator.php プロジェクト: rocksolid-tn/pibx
 public function visitEnumerationEnter(PiBX_AST_Tree $tree)
 {
     $parent = $tree->getParent();
     if ($parent instanceof PiBX_AST_TypeAttribute) {
         $this->xml .= '<value style="element" name="' . $parent->getName() . '"';
         $getter = PiBX_Binding_Names::createGetterNameFor($tree);
         $setter = PiBX_Binding_Names::createSetterNameFor($tree);
         $this->xml .= ' get-method="' . $getter . '"';
         $this->xml .= ' set-method="' . $setter . '"';
         $this->xml .= '/>';
         return false;
     }
     return true;
 }