/** * Duplicate widget action * * This function is executed after the widget has been duplicated. * All widget data is duplicated automatically. This method is used only in case a widget * needs to do some maintenance tasks on duplication. * * @param int $oldId Old widget ID * @param int $newId Duplicated widget ID * @param array $data Data that has been duplicated from old widget to the new one * @return array */ public function duplicate($oldId, $newId, $data) { $oldItems = Model::widgetItems($oldId); foreach ($oldItems as $item) { $item['widgetId'] = $newId; unset($item['id']); Model::addItem($item); } }