_init('admin/variable'); } /** * @return array|bool * @throws Exception * @throws Zend_Validate_Exception */ public function validate() { $errors = array(); if (!Zend_Validate::is($this->getVariableName(), 'NotEmpty')) { $errors[] = Mage::helper('adminhtml')->__('Variable Name is required field.'); } if (!Zend_Validate::is($this->getVariableName(), 'Regex', array('/^[-_a-zA-Z0-9\/]*$/'))) { $errors[] = Mage::helper('adminhtml')->__('Variable Name is incorrect.'); } if (!in_array($this->getIsAllowed(), array('0', '1'))) { $errors[] = Mage::helper('adminhtml')->__('Is Allowed is required field.'); } if (empty($errors)) { return true; } return $errors; } /** * Check is config directive with given path can be parsed via configDirective method * * @param $path string * @return int */ public function isPathAllowed($path) { /** @var Mage_Admin_Model_Resource_Variable_Collection $collection */ $collection = Mage::getResourceModel('admin/variable_collection'); $collection->addFieldToFilter('variable_name', array('eq' => $path)) ->addFieldToFilter('is_allowed', array('eq' => 1)); return $collection->load()->count(); } }