Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request. Small but useful. Entity class. #1176

Closed
nowackipawel opened this issue Aug 22, 2018 · 4 comments
Closed

Feature request. Small but useful. Entity class. #1176

nowackipawel opened this issue Aug 22, 2018 · 4 comments
Labels
enhancement PRs that improve existing functionalities in progress

Comments

@nowackipawel
Copy link
Contributor

nowackipawel commented Aug 22, 2018

There is an feature which allows to cast value of attribute of entity.
Could someone add another options to switch in Entity::castAs($value, string $type)
i.e. like this:

			case 'json-array':
				if (is_string($value) && (strpos($value, '[') === 0 || strpos($value, '{') === 0))
				{
					$value = json_decode($value, true);
				}
				break;
			case 'json-object':
				if (is_string($value) && (strpos($value, '[') === 0 || strpos($value, '{') === 0))
				{
					$value = json_decode($value, false);
				}
				break;

imho it will be useful.

@InsiteFX
Copy link
Contributor

You should ask this in the CodeIgniter CI 4 Forums not here, this is only for reporting bugs etc;

@lonnieezell
Copy link
Member

I'm not opposed to this. Though I believe there are some security risks when storing json values as an array and not an object, so we might consider not checking for square brackets, just curly braces.

Care to submit a PR?

nowackipawel added a commit to nowackipawel/ci4-old that referenced this issue Aug 30, 2018
I've changed name which i proposed before (json-object -> json) cuz I use default parameter for json_decode($value, [$assoc = false]) in calling.
@jim-parry jim-parry added enhancement PRs that improve existing functionalities in progress labels Oct 19, 2018
@jim-parry
Copy link
Contributor

Was this not addressed already, in #1283 ?

@lonnieezell
Copy link
Member

Yes, it did.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement PRs that improve existing functionalities in progress
Projects
None yet
Development

No branches or pull requests

4 participants