Skip to content

Commit

Permalink
Merge pull request #58 from bartjuh4/feat/uppercase-slug-fix
Browse files Browse the repository at this point in the history
Fix issues with uppercase slugs from bolt3 and some minor fixes
  • Loading branch information
bobdenotter authored Mar 22, 2022
2 parents 10ea991 + e48b5bc commit b2757ee
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace BobdenOtter\Conimex;

use Bolt\Common\Str;
use Bolt\Configuration\Config;
use Bolt\Configuration\Content\ContentType;
use Bolt\Controller\Backend\ContentEditController;
Expand Down Expand Up @@ -144,7 +145,7 @@ private function importRecord(ContentType $contentType, Collection $record): voi
}

/** @var Content $content */
$content = $this->contentRepository->findOneBySlug($slug, $contentType);
$content = $this->contentRepository->findOneBySlug(Str::slug($slug), $contentType);

if (! $content) {
$content = new Content($contentType);
Expand Down
14 changes: 13 additions & 1 deletion src/SelectFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ private function populateSelectFieldReferencedData($selectFieldData, $selectFiel
foreach ($selectFieldData as $selectFieldValue) {
$data[] = $this->querySelectFieldReferencedData($selectFieldDefinition, $selectFieldValue);
}
} else {

return $data;
}

if (!empty($selectFieldData)) {
$data[] = $this->querySelectFieldReferencedData($selectFieldDefinition, $selectFieldData);
}

Expand Down Expand Up @@ -139,11 +143,19 @@ private function querySelectFieldReferencedData($selectFieldDefinition, $selectF

private function fetchReferencedRecordSlug($contentType, $selectFieldValue)
{
if (empty($selectFieldValue)) {
return;
}

$criteria['contentType'] = $contentType;
$criteria['id'] = $selectFieldValue;

$referencedRecord = $this->contentRepository->findBy($criteria, [], 1);

if (empty($referencedRecord)) {
return;
}

return $referencedRecord[0]->getFieldValues()['slug'];
}
}
Expand Down

0 comments on commit b2757ee

Please sign in to comment.