Beispiel #1
0
 /**
  * add new attribute
  * @access public
  * @param Ultimate_ModuleCreator_Model_Attribute $attribute
  * @return Ultimate_ModuleCreator_Model_Entity
  * @author Marius Strajeru <*****@*****.**>
  */
 public function addAttribute(Ultimate_ModuleCreator_Model_Attribute $attribute)
 {
     $attribute->setEntity($this);
     if (isset($this->_attribtues[$attribute->getCode()])) {
         throw new Ultimate_ModuleCreator_Exception(Mage::helper('modulecreator')->__('An attribute with the code "%s" already exists for entity "%s"', $attribute->getCode(), $this->getNameSingular()));
     }
     $this->_preparedAttributes = false;
     $this->_attribtues[$attribute->getCode()] = $attribute;
     $allowedTypes = array('text' => 'Text', 'int' => 'Integer', 'decimal' => 'Decimal');
     if ($attribute->getIsName()) {
         if (!in_array($attribute->getType(), array_keys($allowedTypes))) {
             throw new Ultimate_ModuleCreator_Exception(Mage::helper('modulecreator')->__('An attribute that acts as name must have the type %s.', implode(', ', array_values($allowedTypes))));
         }
         $this->_nameAttribute = $attribute;
     }
     if ($attribute->getEditor()) {
         $this->setEditor(true);
     }
     $this->_placeholders = array();
     return $this;
 }
 /**
  * get the attribute code for the name attribute
  *
  * @access public
  * @return string
  * @author Marius Strajeru <*****@*****.**>
  */
 public function getNameAttributeCode()
 {
     return $this->_nameAttribute->getCode();
 }