Skip to content

Commit

Permalink
Rename mapping from parent to parentId
Browse files Browse the repository at this point in the history
The attribute `parentId` is used in Craft to signify the value of the
parent element, if any.  Therefore, the mapping handle should also be
`parentId`.

This patch changes the mapping handle from `parent` into `parentId`.
This allows the comparison code to properly verify that an existing
parent already exists.  Without this patch the current comparison will
use the `parent` property that does not exist in a Craft entry.  This
should have been `parentId` which does exist.

Note that this patch is *not* backwards compatible, all imports that
have been configured with a parent using handle `parent` must
reconfigure the parent so it uses the renamed handle `parentId`.

Perhaps it is worth the time to create a migration for this?
  • Loading branch information
boudewijn-zicht committed May 8, 2023
1 parent eaac8e3 commit 4a673af
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/elements/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function afterSave($data, $settings): void
* @throws ElementNotFoundException
* @throws Exception
*/
protected function parseParent($feedData, $fieldInfo): ?int
protected function parseParentId($feedData, $fieldInfo): ?int
{
$value = $this->fetchSimpleValue($feedData, $fieldInfo);
$default = DataHelper::fetchDefaultArrayValue($fieldInfo);
Expand Down
2 changes: 1 addition & 1 deletion src/elements/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ protected function parseExpiryDate($feedData, $fieldInfo): DateTime|bool|array|C
* @throws ElementNotFoundException
* @throws Exception
*/
protected function parseParent($feedData, $fieldInfo): ?int
protected function parseParentId($feedData, $fieldInfo): ?int
{
$value = $this->fetchSimpleValue($feedData, $fieldInfo);
$default = DataHelper::fetchDefaultArrayValue($fieldInfo);
Expand Down
2 changes: 1 addition & 1 deletion src/templates/_includes/elements/categories/map.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}, {
type: 'categories',
name: 'Parent',
handle: 'parent',
handle: 'parentId',
instructions: 'Select a parent category to import these categories under.'|t('feed-me'),
default: {
type: 'elementselect',
Expand Down
2 changes: 1 addition & 1 deletion src/templates/_includes/elements/entries/map.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
{% set fields = fields|push({
type: 'entries',
name: 'Parent',
handle: 'parent',
handle: 'parentId',
instructions: 'Select a parent entry to import these entries under.'|t('feed-me'),
default: {
type: 'elementselect',
Expand Down

0 comments on commit 4a673af

Please sign in to comment.