Skip to content

Fix filesystem import demo#1834

Merged
mvorisek merged 4 commits intodevelopfrom
fix_1827_no_null_parent
Aug 27, 2022
Merged

Fix filesystem import demo#1834
mvorisek merged 4 commits intodevelopfrom
fix_1827_no_null_parent

Conversation

@mvorisek
Copy link
Copy Markdown
Member

fixes #1827

when custom path was input:

image

it was skipped for import, as it did not match the filtered items

@mvorisek mvorisek marked this pull request as ready for review August 27, 2022 21:23
@mvorisek mvorisek force-pushed the fix_1827_no_null_parent branch from 6ca2b48 to 7bf745d Compare August 27, 2022 21:35
['id' => 364, 'name' => 'TagTest.php', 'type' => 'php', 'is_folder' => false, 'parent_folder_id' => 341],
['id' => 365, 'name' => 'ViewTest.php', 'type' => 'php', 'is_folder' => false, 'parent_folder_id' => 341],
$model->import([
['id' => 1, 'name' => '.gitattributes', 'type' => 'gitattributes', 'is_folder' => false, 'parent_folder_id' => null],
Copy link
Copy Markdown
Member Author

@mvorisek mvorisek Aug 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

created by:

$m = new Model($db, ['table' => new File($db)]);
$m->getField('id')->actual = $m->table->fieldName()->id;
$m->addField('name', ['type' => 'string', 'actual' => $m->table->fieldName()->name]);
$m->addField('type', ['type' => 'string', 'actual' => $m->table->fieldName()->type]);
$m->addField('is_folder', ['type' => 'boolean', 'actual' => $m->table->fieldName()->is_folder]);
$m->addField('parent_folder_id', ['type' => 'integer', 'actual' => $m->table->fieldName()->parent_folder_id]);
$m->setOrder('id');

$res = $m->export();
$aiOffset = reset($res)['id'] - 1;
foreach ($res as $k => $v) {
    $res[$k]['id'] = $v['id'] - $aiOffset;
    if ($v['parent_folder_id']) {
        $res[$k]['parent_folder_id'] = $v['parent_folder_id'] - $aiOffset;
    }
}

var_export($res);

@mvorisek mvorisek changed the title File filesystem import demo Fix filesystem import demo Aug 27, 2022
@mvorisek mvorisek merged commit a120f0f into develop Aug 27, 2022
@mvorisek mvorisek deleted the fix_1827_no_null_parent branch August 27, 2022 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

File import demo is broken

1 participant