-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from wp-graphql/issue-19-field-type-configurat…
…ion-block Add ACF Field Type Configuration Block
- Loading branch information
Showing
16 changed files
with
1,079 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
export function jsonToPhp(obj) { | ||
const convertArray = (array) => { | ||
return array.map(value => { | ||
if (typeof value === 'object' && value !== null) { | ||
return jsonToPhp(value); | ||
} else if (Array.isArray(value)) { | ||
return convertArray(value); | ||
} else if (typeof value === 'string') { | ||
return `'${value.replace(/'/g, "\\'")}'`; | ||
} else if (typeof value === 'boolean') { | ||
return value ? 'true' : 'false'; | ||
} else { | ||
return value; | ||
} | ||
}).join(", "); | ||
}; | ||
|
||
let result = "array(\n"; | ||
for (const key in obj) { | ||
if (Object.prototype.hasOwnProperty.call(obj, key)) { | ||
const value = obj[key]; | ||
result += `\t\t'${key}' => `; | ||
if (Array.isArray(value)) { | ||
result += convertArray(value) + ",\n"; | ||
} else if (typeof value === 'object' && value !== null) { | ||
result += jsonToPhp(value) + ",\n"; | ||
} else { | ||
result += `${value},\n`; | ||
} | ||
} | ||
} | ||
result += "\t)"; | ||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* Converts a snake case string to PascalCase. | ||
* | ||
* @param {string} str - The snake case string to convert. | ||
* @returns {string} - The PascalCase version of the string. | ||
*/ | ||
export function snakeToPascalCase(str) { | ||
return str | ||
.split('_') | ||
.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) | ||
.join(''); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
13ba870
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check out the recent updates to your Atlas environment:
Learn more about building on Atlas in our documentation.