|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Zikula package. |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright Zikula Foundation - http://zikula.org/ |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Zikula\Bundle\CoreInstallerBundle\Controller; |
|
13
|
|
|
|
|
14
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
15
|
|
|
use Zikula\Core\Response\Ajax\AjaxResponse; |
|
16
|
|
|
|
|
17
|
|
|
class MigrationController extends AbstractController |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @param Request $request |
|
21
|
|
|
* @return AjaxResponse |
|
22
|
|
|
*/ |
|
23
|
|
|
public function migrateAction(Request $request) |
|
24
|
|
|
{ |
|
25
|
|
|
if (!$request->getSession()->has('user_migration_lastuid')) { |
|
26
|
|
|
throw new \InvalidArgumentException('user_migration_lastuid is not set in the Session!'); |
|
27
|
|
|
} |
|
28
|
|
|
$result = $this->container |
|
29
|
|
|
->get('zikula_core_installer.helper.migration_helper') |
|
30
|
|
|
->migrateUsers($request->getSession()->get('user_migration_lastuid')); |
|
31
|
|
|
$request->getSession()->set('user_migration_complete', $request->getSession()->get('user_migration_complete') + $result['complete']); |
|
32
|
|
|
$request->getSession()->set('user_migration_lastuid', $result['lastUid']); |
|
33
|
|
|
if ($request->getSession()->get('user_migration_lastuid') == $request->getSession()->get('user_migration_maxuid')) { |
|
34
|
|
|
$percentComplete = 100; |
|
35
|
|
|
// clean up |
|
36
|
|
|
$request->getSession()->remove('user_migration_count'); |
|
37
|
|
|
$request->getSession()->remove('user_migration_complete'); |
|
38
|
|
|
$request->getSession()->remove('user_migration_lastuid'); |
|
39
|
|
|
$request->getSession()->remove('user_migration_maxuid'); |
|
40
|
|
|
} else { |
|
41
|
|
|
$percentComplete = ceil(100 * $request->getSession()->get('user_migration_complete') / $request->getSession()->get('user_migration_count')); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
return new AjaxResponse([ |
|
45
|
|
|
'percentcomplete' => $percentComplete, |
|
46
|
|
|
]); |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
|