private function AddSetter(Php\Writer $writer, $table, $field)
 {
     $fieldInfo = $this->connection->GetFieldInfo($table, $field);
     $keyInfo = $fieldInfo->KeyInfo();
     //No setter for primary key!
     if ($keyInfo && $keyInfo->IsPrimary()) {
         return;
     }
     $class = $this->ClassName($table);
     $type = $this->GetValueTypeName($table, $field);
     $writer->StartDocComment();
     $writer->AddDocComment('Sets the ' . $this->GetNiceName($field) . ' of the ' . $this->GetNiceName($class) . '.');
     $writer->AddDocComment($type . ' $value', 'param');
     $writer->EndDocComment();
     $param = $this->GetValueParam($type, $fieldInfo->IsNullable());
     $writer->StartFunction('final function Set' . $field, array($param));
     $writer->AddCommand('$this->' . $field . ' = $value');
     $writer->EndFunction();
 }
Exemplo n.º 2
0
 private function TemplateContent()
 {
     $areaCodes = '';
     $writer = new Writer();
     $this->InitAreas();
     $template = PathUtil::CodeTemplate($this->MyBundle(), 'Layout.phtml');
     $templateCode = File::GetContents($template);
     $indent = $this->GetIndent($templateCode, '_{areas}_');
     for ($idx = 0; $idx < count($this->areaNames); ++$idx) {
         $name = $this->areaNames[$idx];
         $writer->StartPhpInline();
         $writer->AddCommandInline('echo $this->RenderArea(\'' . $name . '\')');
         if ($idx < count($this->areaNames) - 1) {
             $writer->EndPhp();
         } else {
             $writer->EndPhpInline();
         }
         if ($idx > 0) {
             $areaCodes .= $indent;
         }
         $areaCodes .= $writer->Flush();
     }
     return str_replace('_{areas}_', $areaCodes, $templateCode);
 }