committed by
Kevin Papst
parent
76d4cba596
commit
65790f1fb7
@@ -1,9 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Kimai package.
|
||||
*
|
||||
* (c) Kevin Papst <kevin@kevinpapst.de>
|
||||
* This file is part of the Kimai time-tracking app.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -34,8 +32,6 @@ use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
/**
|
||||
* Command used to import data from a Kimai v1 installation.
|
||||
* Getting help in improving this script would be fantastic, it currently only handles the most basic use-cases.
|
||||
*
|
||||
* @author Kevin Papst <kevin@kevinpapst.de>
|
||||
*/
|
||||
class KimaiImporterCommand extends Command
|
||||
{
|
||||
@@ -271,7 +267,8 @@ class KimaiImporterCommand extends Command
|
||||
|
||||
$bytesImported = memory_get_usage(true);
|
||||
|
||||
$io->success('Memory usage: ' . PHP_EOL .
|
||||
$io->success(
|
||||
'Memory usage: ' . PHP_EOL .
|
||||
'Start: ' . $this->bytesHumanReadable($bytesStart) . PHP_EOL .
|
||||
'After caching: ' . $this->bytesHumanReadable($bytesCached) . PHP_EOL .
|
||||
'After import: ' . $this->bytesHumanReadable($bytesImported) . PHP_EOL .
|
||||
@@ -321,7 +318,7 @@ class KimaiImporterCommand extends Command
|
||||
protected function deactivateLifecycleCallbacks(Connection $connection)
|
||||
{
|
||||
$allListener = $connection->getEventManager()->getListeners();
|
||||
foreach($allListener as $name => $listener) {
|
||||
foreach ($allListener as $name => $listener) {
|
||||
if (in_array($name, ['prePersist', 'preUpdate'])) {
|
||||
foreach ($listener as $service => $class) {
|
||||
if ($class === TimesheetSubscriber::class) {
|
||||
@@ -340,7 +337,7 @@ class KimaiImporterCommand extends Command
|
||||
protected function bytesHumanReadable($size)
|
||||
{
|
||||
$unit=array('b','kB','MB','GB');
|
||||
return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i];
|
||||
return @round($size/pow(1024, ($i=floor(log($size, 1024)))), 2).' '.$unit[$i];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -429,8 +426,7 @@ class KimaiImporterCommand extends Command
|
||||
$counter = 0;
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
|
||||
foreach ($users as $oldUser)
|
||||
{
|
||||
foreach ($users as $oldUser) {
|
||||
$isActive = (bool)$oldUser['active'] && !(bool)$oldUser['trash'] && !(bool)$oldUser['ban'];
|
||||
$role = ($oldUser['globalRoleID'] == 1) ? User::ROLE_SUPER_ADMIN : User::DEFAULT_ROLE;
|
||||
|
||||
@@ -503,8 +499,7 @@ class KimaiImporterCommand extends Command
|
||||
$counter = 0;
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
|
||||
foreach ($customers as $oldCustomer)
|
||||
{
|
||||
foreach ($customers as $oldCustomer) {
|
||||
$isActive = (bool)$oldCustomer['visible'] && !(bool)$oldCustomer['trash'];
|
||||
$name = $oldCustomer['name'];
|
||||
if (empty($name)) {
|
||||
@@ -573,8 +568,7 @@ class KimaiImporterCommand extends Command
|
||||
$counter = 0;
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
|
||||
foreach ($projects as $oldProject)
|
||||
{
|
||||
foreach ($projects as $oldProject) {
|
||||
$isActive = (bool)$oldProject['visible'] && !(bool)$oldProject['trash'];
|
||||
$customer = $this->customers[$oldProject['customerID']];
|
||||
$name = $oldProject['name'];
|
||||
@@ -641,15 +635,12 @@ class KimaiImporterCommand extends Command
|
||||
$counter = 0;
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
$oldActivityMapping = [];
|
||||
foreach ($activityToProject as $mapping)
|
||||
{
|
||||
foreach ($activityToProject as $mapping) {
|
||||
$oldActivityMapping[$mapping['activityID']] = $mapping['projectID'];
|
||||
}
|
||||
|
||||
foreach ($activities as $oldActivity)
|
||||
{
|
||||
if (isset($oldActivityMapping[$oldActivity['activityID']]))
|
||||
{
|
||||
foreach ($activities as $oldActivity) {
|
||||
if (isset($oldActivityMapping[$oldActivity['activityID']])) {
|
||||
$projectId = $oldActivityMapping[$oldActivity['activityID']];
|
||||
$project = null;
|
||||
|
||||
@@ -756,8 +747,7 @@ class KimaiImporterCommand extends Command
|
||||
$activityCounter = 0;
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
|
||||
foreach ($records as $oldRecord)
|
||||
{
|
||||
foreach ($records as $oldRecord) {
|
||||
$activity = null;
|
||||
$project = null;
|
||||
$activityId = $oldRecord['activityID'];
|
||||
|
||||
Reference in New Issue
Block a user