Exemple #1
0
 /**
  * @see models_ClassGenerator_Defaults_Interface::createMethodToArray
  */
 public function createMethodToArray()
 {
     $resultMethod = new Zend_CodeGenerator_Php_Method();
     $resultMethod->setName('toArray');
     $resultMethod->setVisibility(Zend_CodeGenerator_Php_Property::VISIBILITY_PUBLIC);
     $body = 'return array(' . "\n";
     $columnConstants = $this->_provideSqlColumnConstants();
     if (!empty($columnConstants)) {
         foreach ($columnConstants as $columnConstant => $attribute) {
             /* @var $catp Zend_CodeGenerator_Php_Property */
             //TODO - Später in Konstante!
             $body .= "\t" . 'self::' . $columnConstant . '\' => $this->' . $attribute->getName() . ",\n";
         }
     }
     $body .= ');';
     $resultMethod->setBody($body);
     //Comment
     $docblock = new Zend_CodeGenerator_Php_Docblock();
     $docblock->setLongDescription('Returns the array representation of the object using the table column names as keys.');
     $resultMethod->setDocblock($docblock);
     $this->getClass()->setMethod($resultMethod);
 }