/** * Return editable values configs * * @param string $type Grid block type * @param string $origin Values origin (if null, all values will be returned) * @return array */ public function getEditableValues($type, $origin = null) { if (!isset($this->_editableValues[$type])) { // Build all base configs $fields = $this->_getEditableFields($type); foreach ($fields as $id => $field) { $fields[$id] = $this->_buildEditableFieldConfig($type, $id, $field); } $attributes = $this->_getEditableAttributes($type); foreach ($attributes as $code => $attribute) { $attributes[$code] = $this->_buildEditableAttributeConfig($type, $code, $attribute); } // Dispatch events for each kind of editable values $fieldsResponse = new Varien_Object(array('fields' => $fields)); $attributesResponse = new Varien_Object(array('attributes' => $attributes)); $attributeFieldsResponse = new Varien_Object(array('attribute_fields' => $this->_getEditableAttributeFields($type))); Mage::dispatchEvent('blcg_grid_type_editable_fields', array('response' => $fieldsResponse, 'type_model' => $this, 'block_type' => $type)); Mage::dispatchEvent('blcg_grid_type_editable_attributes', array('response' => $attributesResponse, 'type_model' => $this, 'block_type' => $type)); Mage::dispatchEvent('blcg_grid_type_editable_attribute_fields', array('response' => $attributeFieldsResponse, 'type_model' => $this, 'block_type' => $type)); // Cache the results $this->_editableValues[$type] = array(self::EDITABLE_TYPE_FIELD => $fieldsResponse->getFields(), self::EDITABLE_TYPE_ATTRIBUTE => $attributesResponse->getAttributes(), self::EDITABLE_TYPE_ATTRIBUTE_FIELD => $attributeFieldsResponse->getAttributeFields()); } if (!is_null($origin)) { if (isset($this->_editableValues[$type][$origin])) { return $this->_editableValues[$type][$origin]; } else { return array(); } } else { return $this->_editableValues[$type]; } }