Exemple #1
0
 /**
  * setProperty()
  *
  * @param array|Zend_CodeGenerator_Php_Property $property
  * @return Zend_CodeGenerator_Php_Class
  */
 public function setProperty($property)
 {
     if (is_array($property)) {
         $property = new Zend_CodeGenerator_Php_Property($property);
         $propertyName = $property->getName();
     } elseif ($property instanceof Zend_CodeGenerator_Php_Property) {
         $propertyName = $property->getName();
     } else {
         require_once 'Zend/CodeGenerator/Php/Exception.php';
         throw new Zend_CodeGenerator_Php_Exception('setProperty() expects either an array of property options or an instance of Zend_CodeGenerator_Php_Property');
     }
     if (isset($this->_properties[$propertyName])) {
         require_once 'Zend/CodeGenerator/Php/Exception.php';
         throw new Zend_CodeGenerator_Php_Exception('A property by name ' . $propertyName . ' already exists in this class.');
     }
     $this->_properties[$propertyName] = $property;
     return $this;
 }
Exemple #2
0
 /**
  * setConstant()
  *
  * @param array|Zend_CodeGenerator_Php_Property $const
  * @return Zend_CodeGenerator_Php_Class
  */
 public function setConstant($const)
 {
     if (is_array($const)) {
         $const = new Zend_CodeGenerator_Php_Property($const);
         $constName = $const->getName();
     } elseif ($const instanceof Zend_CodeGenerator_Php_Property) {
         $constName = $const->getName();
     } else {
         require_once 'Zend/CodeGenerator/Php/Exception.php';
         throw new Zend_CodeGenerator_Php_Exception('setConstant() expects either an array of property options or an instance of Zend_CodeGenerator_Php_Property');
     }
     if (!$const->isConst()) {
         require_once 'Zend/CodeGenerator/Php/Exception.php';
         throw new Zend_CodeGenerator_Php_Exception('setProperty() expects argument to define a constant');
     }
     if (isset($this->_constants[$constName])) {
         require_once 'Zend/CodeGenerator/Php/Exception.php';
         throw new Zend_CodeGenerator_Php_Exception('A constant by name ' . $constName . ' already exists in this class.');
     }
     $this->_constants[$constName] = $const;
     return $this;
 }
 /**
  * Extracts the column name from an attribute. Uses the explicit name if given, else the 
  * attributes name. 
  * 
  * @return string
  */
 public static function toColumnName(Zend_CodeGenerator_Php_Property $parAttribute)
 {
     $docblock = $parAttribute->getDocblock();
     if ($docblock) {
         $tags = $docblock->getTags();
         foreach ($tags as $tag) {
             /* @var $tag Zend_CodeGenerator_Php_Docblock_Tag */
             if ($tag->getName() === Model_ClassGenerator_Persistence::$tagColumn) {
                 return $tag->getDescription();
             }
         }
     } else {
         return implode('_', self::explodeCase($parAttribute->getName(), true));
     }
 }
Exemple #4
0
 /**
  * @return string
  */
 protected function _provideColumnConstant(Zend_CodeGenerator_Php_Property $parAttribute)
 {
     $tableName = $this->getPersistenceInformation()->getTableName();
     $tableNameUpper = strtoupper($tableName);
     $columnName = strtoupper($parAttribute->getName());
     return 'DB_COL_' . $tableNameUpper . '_' . strtoupper($columnName);
 }
Exemple #5
0
 /**
  * setProperty()
  *
  * @param array|Zend_CodeGenerator_Php_Property $property
  * @return Zend_CodeGenerator_Php_Class
  */
 public function setProperty($property)
 {
     if (is_array($property)) {
         $property = new Zend_CodeGenerator_Php_Property($property);
         $propertyName = $property->getName();
     } elseif ($property instanceof Zend_CodeGenerator_Php_Property) {
         $propertyName = $property->getName();
     } else {
         // require_once 'Zend/CodeGenerator/Php/Exception.php';
         throw new Zend_CodeGenerator_Php_Exception('setProperty() expects either an array of property options or an instance of Zend_CodeGenerator_Php_Property');
     }
     if (isset($this->_properties[$propertyName])) {
         // require_once 'Zend/CodeGenerator/Php/Exception.php';
         throw new Zend_CodeGenerator_Php_Exception('A property by name ' . $propertyName . ' already exists in this class.');
     }
     $append = true;
     foreach ($this->_properties as &$p) {
         if ($p->getName() === $property->getName()) {
             $p->setDefaultValue($property->getDefaultValue());
             $append = false;
         }
     }
     if ($append === true) {
         $this->_properties[$propertyName] = $property;
     }
     return $this;
 }