mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
Corrected fix for #8032
This commit is contained in:
@ -571,32 +571,34 @@ class PhpManager extends BaseManager
|
||||
*/
|
||||
protected function updateItem($name, $item)
|
||||
{
|
||||
if (isset($this->items[$item->name])) {
|
||||
throw new InvalidParamException("Unable to change the item name. The name '{$item->name}' is already used by another item.");
|
||||
if ($name !== $item->name) {
|
||||
if (isset($this->items[$item->name])) {
|
||||
throw new InvalidParamException("Unable to change the item name. The name '{$item->name}' is already used by another item.");
|
||||
} else {
|
||||
// Remove old item in case of renaming
|
||||
unset($this->items[$name]);
|
||||
|
||||
if (isset($this->children[$name])) {
|
||||
$this->children[$item->name] = $this->children[$name];
|
||||
unset($this->children[$name]);
|
||||
}
|
||||
foreach ($this->children as &$children) {
|
||||
if (isset($children[$name])) {
|
||||
$children[$item->name] = $children[$name];
|
||||
unset($children[$name]);
|
||||
}
|
||||
}
|
||||
foreach ($this->assignments as &$assignments) {
|
||||
if (isset($assignments[$name])) {
|
||||
$assignments[$item->name] = $assignments[$name];
|
||||
unset($assignments[$name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->items[$item->name] = $item;
|
||||
|
||||
if ($name !== $item->name && isset($this->items[$name])) {
|
||||
unset ($this->items[$name]);
|
||||
|
||||
if (isset($this->children[$name])) {
|
||||
$this->children[$item->name] = $this->children[$name];
|
||||
unset ($this->children[$name]);
|
||||
}
|
||||
foreach ($this->children as &$children) {
|
||||
if (isset($children[$name])) {
|
||||
$children[$item->name] = $children[$name];
|
||||
unset ($children[$name]);
|
||||
}
|
||||
}
|
||||
foreach ($this->assignments as &$assignments) {
|
||||
if (isset($assignments[$name])) {
|
||||
$assignments[$item->name] = $assignments[$name];
|
||||
unset($assignments[$name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->saveItems();
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user