Exemple #1
0
 /**
  * get subtype instance
  *
  * @access public
  * @return Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown_Abstract
  * @throws Ultimate_ModuleCreator_Exception
  * @author Marius Strajeru <*****@*****.**>
  */
 public function getSubTypeInstance()
 {
     if (!$this->_subTypeInstance) {
         $type = $this->getAttribute()->getOptionsSource();
         try {
             /** @var Ultimate_ModuleCreator_Helper_Data $helper */
             $helper = Mage::helper('modulecreator');
             $types = $helper->getDropdownSubtypes(false);
             $instanceModel = (string) $types->{$type}->type_model;
             /** @var Ultimate_ModuleCreator_Model_Attribute_Type_Dropdown_Abstract $subtypeInstance */
             $subtypeInstance = Mage::getModel($instanceModel);
             $this->_subTypeInstance = $subtypeInstance;
             $this->_subTypeInstance->setTypeAttribute($this);
         } catch (Exception $e) {
             throw new Ultimate_ModuleCreator_Exception("Invalid dropdown subtype: " . $type);
         }
     }
     return $this->_subTypeInstance;
 }
Exemple #2
0
 /**
  * entity to xml
  * @access protected
  * @param array $arrAttributes
  * @param string $rootName
  * @param bool $addOpenTag
  * @param bool $addCdata
  * @return string
  * @author Marius Strajeru <*****@*****.**>
  */
 protected function __toXml(array $arrAttributes = array(), $rootName = 'entity', $addOpenTag = false, $addCdata = false)
 {
     $xml = '';
     if ($addOpenTag) {
         $xml .= '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
     }
     if (!empty($rootName)) {
         $xml .= '<' . $rootName . '>' . "\n";
     }
     $start = '';
     $end = '';
     if ($addCdata) {
         $start = '<![CDATA[';
         $end = ']]>';
     }
     $xml .= parent::__toXml($this->getXmlAttributes(), '', false, $addCdata);
     $xml .= '<attributes>';
     foreach ($this->getAttributes() as $attribute) {
         $xml .= $attribute->toXml(array(), 'attribute', false, $addCdata);
     }
     $xml .= '</attributes>';
     if (!empty($rootName)) {
         $xml .= '</' . $rootName . '>' . "\n";
     }
     return $xml;
 }
 /**
  * entity to xml
  *
  * @access public
  * @param array $arrAttributes
  * @param string $rootName
  * @param bool $addOpenTag
  * @param bool $addCdata
  * @return string
  * @author Marius Strajeru <*****@*****.**>
  */
 public function toXml(array $arrAttributes = array(), $rootName = 'entity', $addOpenTag = false, $addCdata = false)
 {
     $xml = '';
     if ($addOpenTag) {
         $xml .= '<?xml version="1.0" encoding="UTF-8"?>' . $this->getEol();
     }
     if (!empty($rootName)) {
         $xml .= '<' . $rootName . '>' . $this->getEol();
     }
     $xml .= parent::toXml($this->getXmlAttributes(), '', false, $addCdata);
     $xml .= '<attributes>' . $this->getEol();
     foreach ($this->getAttributes() as $attribute) {
         $xml .= $attribute->toXml(array(), 'attribute', false, $addCdata);
     }
     $xml .= '</attributes>' . $this->getEol();
     if (!empty($rootName)) {
         $xml .= '</' . $rootName . '>' . $this->getEol();
     }
     return $xml;
 }
 /**
  * validate xml condition
  *
  * @access protected
  * @param Ultimate_ModuleCreator_Model_Abstract $entity
  * @param Mage_Core_Model_Config_Element $conditions
  * @param mixed $params
  * @return bool
  * @author Marius Strajeru <*****@*****.**>
  */
 protected function _validateDepend(Ultimate_ModuleCreator_Model_Abstract $entity, Mage_Core_Model_Config_Element $conditions, $params = null)
 {
     if (!$conditions) {
         return true;
     }
     if (!is_array($conditions)) {
         $conditions = $conditions->asArray();
     }
     foreach ($conditions as $condition => $value) {
         if (!$entity->getDataUsingMethod($condition, $params)) {
             return false;
         }
     }
     return true;
 }