Skip to content

Commit af1ddb1

Browse files
authored
Merge pull request #50 from localgovdrupal/fix/1.x/32-remove-order
Fix/1.x/32 remove order
2 parents ff070a7 + 553ec9b commit af1ddb1

File tree

5 files changed

+19
-11
lines changed

5 files changed

+19
-11
lines changed

src/ImportInterface.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Drupal\localgov_publications_importer;
44

55
use Drupal\file\Entity\File;
6+
use Drupal\user\UserInterface;
67

78
/**
89
* Interface for content being imported.
@@ -75,4 +76,14 @@ public function getPipeline(): string;
7576
*/
7677
public function getFile(): ?File;
7778

79+
/**
80+
* Get the creator user.
81+
*/
82+
public function getCreator(): ?UserInterface;
83+
84+
/**
85+
* Set the creator user.
86+
*/
87+
public function setCreator(UserInterface $user): void;
88+
7889
}

src/Plugin/LocalGovImporter/Save/Publication.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public function import(ImportInterface $import): ?NodeInterface {
6161
$publicationPage = $nodeStorage->create([
6262
'type' => 'localgov_publication_page',
6363
'title' => $page->getTitle(),
64+
'uid' => $import->getCreator()->id(),
6465
'book' => $book,
6566
]);
6667

src/Plugin/LocalGovImporter/Transform/Linebreaks.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,4 @@ public function transformContent(string $content): string {
2222
return trim(str_replace("\t\n", ' ', $content));
2323
}
2424

25-
/**
26-
* {@inheritDoc}
27-
*/
28-
public function order(): int {
29-
return 30;
30-
}
31-
3225
}

tests/src/Functional/ExtractAndSaveTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ public function testExtractAndSaveAsPublications($fileName, $title, $pageCount):
6868

6969
$node = $savePlugin->import($import);
7070
$this->assertInstanceOf(NodeInterface::class, $node);
71+
72+
$this->assertEquals($import->getCreator()->id(), $node->getOwner()->id());
7173
}
7274

7375
}

tests/src/Functional/FileProviderTrait.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,21 @@ public function createImport($fileName): ImportInterface {
5757
$file_system = \Drupal::service('file_system');
5858
$file_system->copy($fileName, $targetLocation, FileExists::Replace);
5959

60+
$user = $this->drupalCreateUser();
61+
6062
$file = File::create([
6163
'filename' => basename($fileName),
6264
'uri' => $targetLocation,
6365
'status' => 1,
64-
'uid' => 1,
66+
'uid' => $user->id(),
6567
]);
6668
$file->save();
6769

6870
$import = Import::create([
6971
'file' => $file,
7072
'title' => $file->getFilename(),
71-
// We may not need these.
72-
'creator' => NULL,
73-
'pipeline' => '',
73+
'creator' => $user,
74+
'pipeline' => 'standard',
7475
]);
7576

7677
$import->save();

0 commit comments

Comments
 (0)