Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mage_Eav - DOC block update #771

Merged
merged 3 commits into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,19 @@ abstract class Mage_Eav_Block_Adminhtml_Attribute_Edit_Main_Abstract extends Mag
{
protected $_attribute = null;

/**
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
* @return $this
*/
public function setAttributeObject($attribute)
{
$this->_attribute = $attribute;
return $this;
}

/**
* @return Mage_Catalog_Model_Resource_Eav_Attribute
*/
public function getAttributeObject()
{
if (null === $this->_attribute) {
Expand All @@ -53,7 +60,7 @@ public function getAttributeObject()
/**
* Preparing default form elements for editing attribute
*
* @return Mage_Eav_Block_Adminhtml_Attribute_Edit_Main_Abstract
* @inheritDoc
*/
protected function _prepareForm()
{
Expand All @@ -65,7 +72,8 @@ protected function _prepareForm()
'method' => 'post'
));

$fieldset = $form->addFieldset('base_fieldset',
$fieldset = $form->addFieldset(
'base_fieldset',
array('legend'=>Mage::helper('eav')->__('Attribute Properties'))
);
if ($attributeObject->getAttributeId()) {
Expand All @@ -78,8 +86,10 @@ protected function _prepareForm()

$yesno = Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray();

$validateClass = sprintf('validate-code validate-length maximum-length-%d',
Mage_Eav_Model_Entity_Attribute::ATTRIBUTE_CODE_MAX_LENGTH);
$validateClass = sprintf(
'validate-code validate-length maximum-length-%d',
Mage_Eav_Model_Entity_Attribute::ATTRIBUTE_CODE_MAX_LENGTH
);
$fieldset->addField('attribute_code', 'text', array(
'name' => 'attribute_code',
'label' => Mage::helper('eav')->__('Attribute Code'),
Expand Down Expand Up @@ -169,7 +179,7 @@ protected function _prepareForm()
/**
* Initialize form fileds values
*
* @return Mage_Eav_Block_Adminhtml_Attribute_Edit_Main_Abstract
* @inheritDoc
*/
protected function _initFormValues()
{
Expand Down Expand Up @@ -217,5 +227,4 @@ protected function _afterToHtml($html)
->createBlock('eav/adminhtml_attribute_edit_js')->toHtml();
return $html.$jsScripts;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,28 @@ public function __construct()
/**
* Preparing layout, adding buttons
*
* @return Mage_Eav_Block_Adminhtml_Attribute_Edit_Options_Abstract
* @inheritDoc
*/
protected function _prepareLayout()
{
$this->setChild('delete_button',
$this->setChild(
'delete_button',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData(array(
'label' => Mage::helper('eav')->__('Delete'),
'class' => 'delete delete-option'
)));
))
);

$this->setChild('add_button',
$this->setChild(
'add_button',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData(array(
'label' => Mage::helper('eav')->__('Add Option'),
'class' => 'add',
'id' => 'add_new_option_button'
)));
))
);
return parent::_prepareLayout();
}

Expand Down Expand Up @@ -138,6 +142,7 @@ public function getOptionValues()
->load();

$helper = Mage::helper('core');
/** @var Mage_Eav_Model_Entity_Attribute_Option $option */
foreach ($optionCollection as $option) {
$value = array();
if (in_array($option->getId(), $defaultValues)) {
Expand Down Expand Up @@ -199,6 +204,7 @@ public function getStoreOptionValues($storeId)
->setAttributeFilter($this->getAttributeObject()->getId())
->setStoreFilter($storeId, false)
->load();
/** @var Mage_Eav_Model_Entity_Attribute_Option $item */
foreach ($valuesCollection as $item) {
$values[$item->getId()] = $item->getValue();
}
Expand All @@ -216,5 +222,4 @@ public function getAttributeObject()
{
return Mage::registry('entity_attribute');
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ protected function _prepareColumns()
/**
* Return url of given row
*
* @param Mage_Catalog_Model_Resource_Eav_Attribute $row
* @return string
*/
public function getRowUrl($row)
{
return $this->getUrl('*/*/edit', array('attribute_id' => $row->getAttributeId()));
}

}
2 changes: 1 addition & 1 deletion app/code/core/Mage/Eav/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

class Mage_Eav_Exception extends Mage_Core_Exception
class Mage_Eav_Exception extends Mage_Core_Exception
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
*/
class Mage_Eav_Model_Adminhtml_System_Config_Source_Inputtype
{
/**
* @return array
*/
public function toOptionArray()
{
return array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Mage_Eav_Model_Adminhtml_System_Config_Source_Inputtype_Validator extends
public function __construct()
{
//set data haystack
/** @var $helper Mage_Eav_Helper_Data */
/** @var Mage_Eav_Helper_Data $helper */
$helper = Mage::helper('eav');
$haystack = $helper->getInputTypesValidatorData();

Expand All @@ -58,7 +58,7 @@ public function __construct()
/**
* Initialize message templates with translating
*
* @return Mage_Adminhtml_Model_Core_File_Validator_SavePath_Available
* @return Mage_Eav_Model_Adminhtml_System_Config_Source_Inputtype_Validator
*/
protected function _initMessageTemplates()
{
Expand Down
6 changes: 3 additions & 3 deletions app/code/core/Mage/Eav/Model/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function getWebsite()
/**
* Processing object after save data
*
* @return Mage_Eav_Model_Attribute
* @inheritDoc
*/
protected function _afterSave()
{
Expand Down Expand Up @@ -115,7 +115,7 @@ public function getValidateRules()
$rules = $this->getData('validate_rules');
if (is_array($rules)) {
return $rules;
} else if (!empty($rules)) {
} elseif (!empty($rules)) {
return unserialize($rules);
}
return array();
Expand All @@ -131,7 +131,7 @@ public function setValidateRules($rules)
{
if (empty($rules)) {
$rules = null;
} else if (is_array($rules)) {
} elseif (is_array($rules)) {
$rules = serialize($rules);
}
$this->setData('validate_rules', $rules);
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Eav/Model/Attribute/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Mage_Eav_Model_Attribute_Data
*/
public static function factory(Mage_Eav_Model_Attribute $attribute, Mage_Core_Model_Abstract $entity)
{
/* @var $dataModel Mage_Eav_Model_Attribute_Data_Abstract */
/* @var Mage_Eav_Model_Attribute_Data_Abstract $dataModel */
$dataModelClass = $attribute->getDataModel();
if (!empty($dataModelClass)) {
if (empty(self::$_dataModels[$dataModelClass])) {
Expand Down
6 changes: 3 additions & 3 deletions app/code/core/Mage/Eav/Model/Attribute/Data/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ protected function _dateFilterFormat($format = null)
$this->_dateFilterFormat = Mage_Core_Model_Locale::FORMAT_TYPE_SHORT;
}
return Mage::app()->getLocale()->getDateFormat($this->_dateFilterFormat);
} else if ($format === false) {
} elseif ($format === false) {
// reset value
$this->_dateFilterFormat = null;
return $this;
Expand Down Expand Up @@ -273,7 +273,7 @@ protected function _applyOutputFilter($value)
* Validate value by attribute input validation rule
*
* @param string $value
* @return string
* @return string|array|true
*/
protected function _validateInputRule($value)
{
Expand Down Expand Up @@ -453,7 +453,7 @@ protected function _validateInputRule($value)
Zend_Validate_Date::FALSEFORMAT
);
if (!$validator->isValid($value)) {
return array_unique($validator->getMessages());
return array_unique($validator->getMessages());
}

break;
Expand Down
12 changes: 7 additions & 5 deletions app/code/core/Mage/Eav/Model/Attribute/Data/Datetime.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ protected function _getFormFilter()
if ($filterCode == 'datetime') {
$filter = new $filterClass(
$this->_getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
$this->_getLocale()->getLocale());
} else {
$filter = new $filterClass();
}
$this->_getLocale()->getLocale()
);
} else {
$filter = new $filterClass();
}
return $filter;
}
return false;
Expand All @@ -61,7 +62,8 @@ protected function _getFormFilter()
*
* @return Mage_Core_Model_Locale
*/
protected function _getLocale(){
protected function _getLocale()
{
return Mage::app()->getLocale();
}
}
8 changes: 5 additions & 3 deletions app/code/core/Mage/Eav/Model/Attribute/Data/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ protected function _validateByRules($value)
/**
* Check protected file extension
*/
/** @var $validator Mage_Core_Model_File_Validator_NotProtectedExtension */
/** @var Mage_Core_Model_File_Validator_NotProtectedExtension $validator */
$validator = Mage::getSingleton('core/file_validator_notProtectedExtension');
if (!$validator->isValid($extension)) {
return $validator->getMessages();
Expand Down Expand Up @@ -152,7 +152,7 @@ protected function _validateByRules($value)
*
* @param array|string $value
* @throws Mage_Core_Exception
* @return boolean
* @return true|array
*/
public function validateValue($value)
{
Expand Down Expand Up @@ -194,9 +194,9 @@ public function validateValue($value)
/**
* Export attribute value to entity model
*
* @param Mage_Core_Model_Abstract $entity
* @param array|string $value
* @return $this
* @throws Mage_Core_Exception
*/
public function compactValue($value)
{
Expand Down Expand Up @@ -263,7 +263,9 @@ public function restoreValue($value)
/**
* Return formated attribute value from entity model
*
* @param string $format
* @return string|array
* @throws Mage_Core_Exception
*/
public function outputValue($format = Mage_Eav_Model_Attribute_Data::OUTPUT_FORMAT_TEXT)
{
Expand Down
8 changes: 4 additions & 4 deletions app/code/core/Mage/Eav/Model/Attribute/Data/Multiline.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ public function validateValue($value)
/**
* Export attribute value to entity model
*
* @param Mage_Core_Model_Abstract $entity
* @param array|string $value
* @return $this
* @inheritDoc
*/
public function compactValue($value)
{
Expand All @@ -119,7 +117,7 @@ public function compactValue($value)
* Restore attribute value from SESSION to entity model
*
* @param array|string $value
* @return $this
* @return Mage_Eav_Model_Attribute_Data_Text
*/
public function restoreValue($value)
{
Expand All @@ -129,7 +127,9 @@ public function restoreValue($value)
/**
* Return formated attribute value from entity model
*
* @param string $format
* @return string|array
* @throws Mage_Core_Exception
*/
public function outputValue($format = Mage_Eav_Model_Attribute_Data::OUTPUT_FORMAT_TEXT)
{
Expand Down
5 changes: 3 additions & 2 deletions app/code/core/Mage/Eav/Model/Attribute/Data/Multiselect.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ public function extractValue(Zend_Controller_Request_Http $request)
/**
* Export attribute value to entity model
*
* @param array|string $value
* @return $this
* @inheritDoc
*/
public function compactValue($value)
{
Expand All @@ -66,7 +65,9 @@ public function compactValue($value)
/**
* Return formated attribute value from entity model
*
* @param string $format
* @return string|array
* @throws Mage_Core_Exception
*/
public function outputValue($format = Mage_Eav_Model_Attribute_Data::OUTPUT_FORMAT_TEXT)
{
Expand Down
2 changes: 2 additions & 0 deletions app/code/core/Mage/Eav/Model/Attribute/Data/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ protected function _getOptionText($value)
/**
* Return formated attribute value from entity model
*
* @param string $format
* @return string|array
* @throws Mage_Core_Exception
*/
public function outputValue($format = Mage_Eav_Model_Attribute_Data::OUTPUT_FORMAT_TEXT)
{
Expand Down
Loading