Merge remote-tracking branch 'upstream/master'

This commit is contained in:
d-buchmann 2025-08-14 15:02:05 +02:00
commit 1db857ed2d
6 changed files with 526 additions and 570 deletions

View file

@ -1 +1 @@
1.17.2 1.17.3

View file

@ -39,7 +39,7 @@
"@ckeditor/ckeditor5-block-quote": "^44.0.0", "@ckeditor/ckeditor5-block-quote": "^44.0.0",
"@ckeditor/ckeditor5-code-block": "^44.0.0", "@ckeditor/ckeditor5-code-block": "^44.0.0",
"@ckeditor/ckeditor5-dev-translations": "^43.0.1", "@ckeditor/ckeditor5-dev-translations": "^43.0.1",
"@ckeditor/ckeditor5-dev-utils": "^43.0.1", "@ckeditor/ckeditor5-dev-utils": "43.0.*",
"@ckeditor/ckeditor5-editor-classic": "^44.0.0", "@ckeditor/ckeditor5-editor-classic": "^44.0.0",
"@ckeditor/ckeditor5-essentials": "^44.0.0", "@ckeditor/ckeditor5-essentials": "^44.0.0",
"@ckeditor/ckeditor5-find-and-replace": "^44.0.0", "@ckeditor/ckeditor5-find-and-replace": "^44.0.0",

View file

@ -57,6 +57,7 @@ class EntityImporter
/** /**
* Creates many entries at once, based on a (text) list of name. * Creates many entries at once, based on a (text) list of name.
* The created entities are not persisted to database yet, so you have to do it yourself. * The created entities are not persisted to database yet, so you have to do it yourself.
* It returns all entities in the hierachy chain (even if they are already persisted).
* *
* @template T of AbstractNamedDBElement * @template T of AbstractNamedDBElement
* @param string $lines The list of names seperated by \n * @param string $lines The list of names seperated by \n
@ -132,32 +133,38 @@ class EntityImporter
//We can only use the getNewEntityFromPath function, if the repository is a StructuralDBElementRepository //We can only use the getNewEntityFromPath function, if the repository is a StructuralDBElementRepository
if ($repo instanceof StructuralDBElementRepository) { if ($repo instanceof StructuralDBElementRepository) {
$entities = $repo->getNewEntityFromPath($new_path); $entities = $repo->getNewEntityFromPath($new_path);
$entity = end($entities); if ($entities === []) {
if ($entity === false) {
throw new InvalidArgumentException('getNewEntityFromPath returned an empty array!'); throw new InvalidArgumentException('getNewEntityFromPath returned an empty array!');
} }
} else { //Otherwise just create a new entity } else { //Otherwise just create a new entity
$entity = new $class_name; $entity = new $class_name;
$entity->setName($name); $entity->setName($name);
$entities = [$entity];
} }
//Validate entity //Validate entity
$tmp = $this->validator->validate($entity); foreach ($entities as $entity) {
//If no error occured, write entry to DB: $tmp = $this->validator->validate($entity);
if (0 === count($tmp)) { //If no error occured, write entry to DB:
$valid_entities[] = $entity; if (0 === count($tmp)) {
} else { //Otherwise log error $valid_entities[] = $entity;
$errors[] = [ } else { //Otherwise log error
'entity' => $entity, $errors[] = [
'violations' => $tmp, 'entity' => $entity,
]; 'violations' => $tmp,
];
}
} }
$last_element = $entity; $last_element = end($entities);
if ($last_element === false) {
$last_element = null;
}
} }
return $valid_entities; //Only return objects once
return array_values(array_unique($valid_entities));
} }
/** /**

View file

@ -75,8 +75,8 @@ class EntityImporterTest extends WebTestCase
$em = self::getContainer()->get(EntityManagerInterface::class); $em = self::getContainer()->get(EntityManagerInterface::class);
$parent = $em->find(AttachmentType::class, 1); $parent = $em->find(AttachmentType::class, 1);
$results = $this->service->massCreation($lines, AttachmentType::class, $parent, $errors); $results = $this->service->massCreation($lines, AttachmentType::class, $parent, $errors);
$this->assertCount(3, $results); $this->assertCount(4, $results);
$this->assertSame($parent, $results[0]->getParent()); $this->assertSame("Test 1", $results[1]->getName());
//Test for addition of existing elements //Test for addition of existing elements
$errors = []; $errors = [];
@ -113,6 +113,31 @@ EOT;
} }
public function testMassCreationArrow(): void
{
$input = <<<EOT
Test1 -> Test1.1
Test1 -> Test1.2
Test2 -> Test2.1
Test1
Test1.3
EOT;
$errors = [];
$results = $this->service->massCreation($input, AttachmentType::class, null, $errors);
//We have 6 elements, and 0 errors
$this->assertCount(0, $errors);
$this->assertCount(6, $results);
$this->assertEquals('Test1', $results[0]->getName());
$this->assertEquals('Test1.1', $results[1]->getName());
$this->assertEquals('Test1.2', $results[2]->getName());
$this->assertEquals('Test2', $results[3]->getName());
$this->assertEquals('Test2.1', $results[4]->getName());
$this->assertEquals('Test1.3', $results[5]->getName());
}
public function testMassCreationNested(): void public function testMassCreationNested(): void
{ {
$input = <<<EOT $input = <<<EOT
@ -132,15 +157,15 @@ EOT;
//We have 7 elements, and 0 errors //We have 7 elements, and 0 errors
$this->assertCount(0, $errors); $this->assertCount(0, $errors);
$this->assertCount(7, $results); $this->assertCount(8, $results);
$element1 = $results[0]; $element1 = $results[1];
$element11 = $results[1]; $element11 = $results[2];
$element111 = $results[2]; $element111 = $results[3];
$element112 = $results[3]; $element112 = $results[4];
$element12 = $results[4]; $element12 = $results[5];
$element121 = $results[5]; $element121 = $results[6];
$element2 = $results[6]; $element2 = $results[7];
$this->assertSame('Test 1', $element1->getName()); $this->assertSame('Test 1', $element1->getName());
$this->assertSame('Test 1.1', $element11->getName()); $this->assertSame('Test 1.1', $element11->getName());

View file

@ -7157,12 +7157,15 @@ Exampletown</target>
</notes> </notes>
<segment state="translated"> <segment state="translated">
<source>mass_creation.lines.placeholder</source> <source>mass_creation.lines.placeholder</source>
<target>Element 1 <target><![CDATA[Element 1
Element 1.1 Element 1.1
Element 1.1.1 Element 1.1.1
Element 1.2 Element 1.2
Element 2 Element 2
Element 3</target> Element 3
Element 1 -> Element 1.1
Element 1 -> Element 1.2]]></target>
</segment> </segment>
</unit> </unit>
<unit id="TWSqPFi" name="entity.mass_creation.btn"> <unit id="TWSqPFi" name="entity.mass_creation.btn">

1007
yarn.lock

File diff suppressed because it is too large Load diff