本文整理汇总了PHP中Attribute::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Attribute::delete方法的具体用法?PHP Attribute::delete怎么用?PHP Attribute::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Attribute
的用法示例。
在下文中一共展示了Attribute::delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
public function delete()
{
if (parent::delete()) {
$ret = true;
$attributes = $this->getAttributes();
foreach ($attributes as $attribute) {
$attr = new Attribute((int) $attribute['id_attribute']);
$ret &= $attr->delete();
}
return $ret;
}
}
示例2: postProcess
public function postProcess()
{
if (!Combination::isFeatureActive()) {
return;
}
if (!Tools::getValue($this->identifier) && Tools::getValue('id_attribute') && !Tools::getValue('attributeOrderby')) {
// Override var of Controller
$this->table = 'attribute';
$this->className = 'Attribute';
$this->identifier = 'id_attribute';
}
// If it's an attribute, load object Attribute()
if (Tools::getValue('updateattribute') || Tools::isSubmit('deleteattribute') || Tools::isSubmit('submitAddattribute')) {
if ($this->tabAccess['edit'] !== '1') {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
} else {
if (!($object = new Attribute((int) Tools::getValue($this->identifier)))) {
$this->errors[] = Tools::displayError('An error occurred while updating the status for an object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
}
}
if (Tools::getValue('position') !== false && Tools::getValue('id_attribute')) {
$_POST['id_attribute_group'] = $object->id_attribute_group;
if (!$object->updatePosition((int) Tools::getValue('way'), (int) Tools::getValue('position'))) {
$this->errors[] = Tools::displayError('Failed to update the position.');
} else {
Tools::redirectAdmin(self::$currentIndex . '&conf=5&token=' . Tools::getAdminTokenLite('AdminAttributesGroups') . '#details_details_' . $object->id_attribute_group);
}
} else {
if (Tools::isSubmit('deleteattribute') && Tools::getValue('id_attribute')) {
if (!$object->delete()) {
$this->errors[] = Tools::displayError('Failed to delete the attribute.');
} else {
Tools::redirectAdmin(self::$currentIndex . '&conf=1&token=' . Tools::getAdminTokenLite('AdminAttributesGroups'));
}
} else {
if (Tools::isSubmit('submitAddattribute')) {
Hook::exec('actionObjectAttributeAddBefore');
$this->action = 'save';
$id_attribute = (int) Tools::getValue('id_attribute');
// Adding last position to the attribute if not exist
if ($id_attribute <= 0) {
$sql = 'SELECT `position`+1
FROM `' . _DB_PREFIX_ . 'attribute`
WHERE `id_attribute_group` = ' . (int) Tools::getValue('id_attribute_group') . '
ORDER BY position DESC';
// set the position of the new group attribute in $_POST for postProcess() method
$_POST['position'] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
}
$_POST['id_parent'] = 0;
$this->processSave($this->token);
}
}
}
} else {
if (Tools::getValue('submitDel' . $this->table)) {
if ($this->tabAccess['delete'] === '1') {
if (isset($_POST[$this->table . 'Box'])) {
$object = new $this->className();
if ($object->deleteSelection($_POST[$this->table . 'Box'])) {
Tools::redirectAdmin(self::$currentIndex . '&conf=2' . '&token=' . $this->token);
}
$this->errors[] = Tools::displayError('An error occurred while deleting this selection.');
} else {
$this->errors[] = Tools::displayError('You must select at least one element to delete.');
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to delete this.');
}
// clean position after delete
AttributeGroup::cleanPositions();
} else {
if (Tools::isSubmit('submitAdd' . $this->table)) {
Hook::exec('actionObjectAttributeGroupAddBefore');
$id_attribute_group = (int) Tools::getValue('id_attribute_group');
// Adding last position to the attribute if not exist
if ($id_attribute_group <= 0) {
$sql = 'SELECT `position`+1
FROM `' . _DB_PREFIX_ . 'attribute_group`
ORDER BY position DESC';
// set the position of the new group attribute in $_POST for postProcess() method
$_POST['position'] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
}
// clean \n\r characters
foreach ($_POST as $key => $value) {
if (preg_match('/^name_/Ui', $key)) {
$_POST[$key] = str_replace('\\n', '', str_replace('\\r', '', $value));
}
}
parent::postProcess();
} else {
parent::postProcess();
}
}
}
}